I'm working on an iOS app that will create a lot of small objects and floats, and trying to get an idea for how much memory usage it's consuming.
When I run the "Allocations" instrument, it says I have about 2MB of "Live Bytes", and the figure stays roughly constant as I move through the app (spikes up to 3MB or so when the App is busy, but then drops back down to 2MB).
But when I run the "Activity Monitory" instrument, my app's "Real Memory" is 25MB once it finishes launching, and grows rapidly whenever drawing occurs inside my CALayer. In less than a minute, it goes over 100MB.
Why would "Live Bytes" show 2MB, but "Real Memory" shows 100MB?
My CALayer is drawing tons of paths, it pegs the CPU at 100% for a few seconds just to finish a single draw operation, and it's loading all of these points out of an NSData object into CGPoint values, then deallocing them again (The NSData object is a compressed version of the points being drawn, storing deltas from one point to the next, so I keep it in RAM but don't keep the actual CGPoints).
It also caches the result of the drawing in a UIImage, and these are kept in a first-in-first-out array that won't grow to more than about 500KB.
The Real Memory number includes memory blocks which your app has used and already released, but that the OS hasn't bothered to reclaim or reuse yet (but could if needed). Live memory is "dirty" memory which can't be reclaimed by the OS without killing your app, if your app is running and memory gets too tight.
It turns out my problem was
NSZombieEnabled
.Disabling that in Edit Scheme > Run > Arguments > Environment Variables solved the extra memory use.