Live Bytes vs Real Memory in activity monitor on iOS

I am working on an iOS application that will create many small objects and floats, and try to understand how many of them consume memory.

When I run the "Allocations" tool, it says that I have about 2 MB of "live bytes" and this figure remains approximately constant when I move through the application (spikes up to 3 MB or so when the application is busy, but then drops up to 2 MB).

But when I run the Activity Monitoring tool, my Real Memory application is 25 MB after the launch is complete and grows quickly when painting happens inside my CALayer. In less than a minute, it exceeds 100 MB.

Why does "Live Bytes" show 2MB, but "Real Memory" shows 100MB?

My CALayer draws many paths, it binds the processor 100% in a few seconds to finish one drawing operation, and loads all these points from the NSData object into CGPoint values, and then undo them again (NSData object is a compressed version of the selected points, saving the delta from one point to another, so I store it in RAM, but not save the actual CGPoints).

It also caches the drawing result in UIImage, and they are stored in a first-in-first-out array, which does not grow to more than 500 KB.

+10
ios memory-leaks objective-c instruments
Jan 09 '12 at 20:48
source share
2 answers

Turns out my problem was NSZombieEnabled .

Disabling this in Edit Scheme> Run> Arguments> Environment variables allowed the use of additional memory.

+11
Jan 15 2018-12-15T00:
source share

The real memory number includes blocks of memory that your application has used and has already released, but that the OS did not bother to reuse or reuse (but if necessary). Living memory is dirty memory that cannot be recovered by the operating system without killing your application if your application is running and memory becomes too tight.

+13
Jan 10 2018-12-12T00:
source share



All Articles