My app, which uses ARC, does the following:
- Uploads a picture taken by the camera
- Compresses the picture for use as a thumbnail.
- I do this using [UIImage imageWithData:UIImageJPEGRepresentation( original, 0.1f )]
- I set the uncompressed picture reference to nil for ARC to free the memory
Repeating this sequence will mean that several compressed thumbnails are on the screen. After about 7 or 8 pictures, the app wil crash due to low memory.
In Instruments, I am attempting to use Allocations in tandem with Memory Monitor to find the source of my problem.
Some Instruments stats:
Allocation - Live Bytes jumps by about 2 MB after taking a picture, but then goes down by 1.5 MB after original picture reference is set to nil. That seems to be a good thing, but...
Here's an eventual state of the application. #Living seems to be very high relative to the Live Bytes, right?
Live Bytes #Living #Transitory Overall #Overall Bytes
3.72 MB 24538 80679 90.1 MB 105301
Memory Monitor (tracking inspection head) - My application starts up at 7.5 MB and taking one picture results in that increasing by ~13 MB. For the state that I listed above, Memory Monitor says that the app is taking up 72.67 MB of "Real Memory" and 123.79 MB of Virtual Memory.
Given that the Live Bytes are very small, I know I'm doing something right. However, given that the memory footprint in other places is large, I'm also sure I'm doing something very wrong. Any ideas what that might be, or how to track it down?