Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between virtual memory consumption and real memory with Memory Monitor on iOS

I am stuck with an issue in my app. I have been testing up until now mostly on my iPad 3 with occasional checks on my iPad 1 to make sure all is well.

I am playing a UIImageView animation in my app and it keeps quitting with only a "Received memory warning" message before it quits.

I have been using the Object Allocations tool in instruments but according to that, my memory usage is way low. So after researching for a bit I came across this post by Mr. Larson: https://stackoverflow.com/a/5627221/329900

Now I am using the Memory Monitor tool instead. However, I don't understand why I am quitting. The 1st gen. iPad has 256MB of ram. Now I know I can't use all of that...some say you shouldn't use more than 100MB.

Is that real memory though, or virtual memory...or maybe some combination? My real memory is consistently between 20 - 25MB but the virtual is around 190 - 205MB when it crashes.

Here's a screenshot:enter image description here

Anyone able to shed some light on this?

like image 253
daveMac Avatar asked Feb 12 '13 18:02

daveMac


1 Answers

The WWDC (Session 242) video found by searching for iOS App Performance: Memory in the WWDC 2012 Session Videos page will give you a better understanding of the difference between VM and real memory.

But here is a quick overview: A pointer Range = 2^32 = 4GB This is larger then the physical memory on any device(apple has shipped). This is done by taking all available space and dividing it up into 4kb chunks. Not all the memory your application can access is in physical memory at the same time. These 4kb chunks are call pages. Your allocations get split out of larger chunks of virtual memory. Then these virtual memory objects get mapped to physical memory.

like image 132
Jaybit Avatar answered Oct 23 '22 12:10

Jaybit