Is there a way to get how much memory a variable is using?
I mean, I have a dictionary with images inside it and if it grows too big I want to delete some of the key/values pairs inside of it.
This is precisely what NSCache is designed to handle automatically. To your deeper question, not like you're thinking. "How much memory does X use" is a very fuzzy and complicated question, particularly when you're thinking about UIImage which can wildly change its memory usage at any time, and which includes lots of memory that isn't counted directly against your program. UIImage already does a lot of memory optimization; study its docs before you reinvent what it's already doing.