Search code examples
iosmemory-leaksxcode-instruments

iOS profiling allocations not showing UIImage object created through code


I am doing little analysis on memory allocations for UIImageView and UIImage.

To do that I am loading an image of size 2.1MB in image view, but when I profile the memory allocations through xcode-instruments it shows that live bytes are 741.50KB & overall bytes are 1.56MB.

Looking down the list of all memory allocations, I could not find an entry for alloc called by me.

This is the code that I have in my view controller.

self.imageView.image = [[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"img_background" ofType:@"png"]] autorelease];

I am just wondering why total size shown in xcode-instrument is far too less than expected. Also why the above alloc is not listed in memory allocations.


Solution

  • Check here https://stackoverflow.com/a/7575099/314983 Allocation instrument does not include memory consumed by OpenGL ES - data of UIImage is, in fact, used by OpenGL ES.