9

I get frequent memory warnings in my application but I don't know why. Here is the snapshot of allocation instruments.

Instruments

I know that we don't have any control over virtual memory assigned to us but I am trying to understand what information does that number 26.50 MB means for a developer.

 1. What does a high VM means ? Does it lead to a jetsam ? Is that cause of any other concern ?
 2. Is this value dependent on device ?
 3. Does a low vm means that your app is memory efficient 
 4. Does a high VM leads to memory warnings in your app ?
 5. What cause this value to change ? 
 6. What steps should a developer take when they see a high vm for their app (like 300 MB) ? 
 7. Is VM tracker instrument related to this value ?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Kunal Balani
  • 4,739
  • 4
  • 36
  • 73

1 Answers1

13

Anonymous VM covers a lot of things, some of which are things you want to minimize and some that are generally less important. The short version of "anonymous VM" is that it's addresses you have mapped but not named. Heap allocations get "named" which lets you track them as objects. But there are lots (and lots) of non-objecty things that fall into the "anonymous VM" bucket.

Things allocated with malloc can wind up in this region. But also memory mapped files. Your executable is a memory mapped file, but since it's never dirty, parts of it can be swapped out. So "it's complicated." But in big, vague terms, yes, you do care about this section, but you may not care about all of it very much. Heap allocations tends to track your ObjC stuff. Anonymous VM often tracks things that you don't have a lot of direct control over (like CALayer backing storage).

All that said, the Instruments output you provide doesn't look like any major problem. I suspect it's not indicative of a time you're pressuring memory. You'll need to get yourself into a memory warning situation and see what's going on then, and dig into the specifics of what is using memory.

For much more detail on this, you should watch WWDC 2013 session 704 "Building Efficient OS X Apps" which goes into depth on much of this. While iOS has a somewhat different memory system, and some OS X tools aren't available on iOS, many of the concepts still apply.

Guillaume Algis
  • 10,705
  • 6
  • 44
  • 72
Rob Napier
  • 286,113
  • 34
  • 456
  • 610