title: Live Bytes vs Real Memory in Activity Monitor on iOS
body: <p>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.</p>
  
  <p>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).</p>
  
  <p>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.</p>
  
  <p>Why would "Live Bytes" show 2MB, but "Real Memory" shows 100MB?</p>
  
  <p>My CALayer is drawing <em>tons</em> 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).</p>
  
  <p>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.</p>