86

I'm using Instument's ObjectAlloc tool in an attempt to understand what the memory my application (iPhone) is doing and when and where it is doing it.

I would really like a basic explanation of these statistics:

  • Live Bytes
  • #Living
  • #Transitory
  • Overall Bytes

When I am trying to work out how much memory my application is using, am I to look at Live Bytes or Overall Bytes? Does this include leaked memory? What are Transitory objects?

Thanks

Ross
  • 14,266
  • 12
  • 60
  • 91

2 Answers2

110

ObjectAlloc tracks all memory allocation and deallocation over the time your program is running.

The Living bytes, or Net bytes is how much memory your application is using at the time you select in the timeline. That will include leaked memory, since leaked memory is never deallocated.

#Living is how many allocations of a certain size/object type happened (and are still allocated). This is very useful when looking for leaks.

For example, if you repetitively perform an action (like coming in an out of a modal view controller), and you see that #Living of an object grows by the same amount each time, then you're probably leaking those objects. You can then confirm by drilling down and seeing the exact line of code that is allocating the objects, and even see the time index each one was created.

Overall bytes includes memory that has been released. It's useful to track that number for performance optimization purposes, but not if you're just trying to see your current memory footprint or look for leaks.

Shekhar Gupta
  • 6,206
  • 3
  • 30
  • 50
Ken Aspeslagh
  • 11,484
  • 2
  • 36
  • 42
  • 3
    What would you be trying to optimize in terms of Overall Bytes? Trying to keep the number small means better performance? – Dan Rosenstark Oct 25 '11 at 05:17
  • 4
    Yes, correct. A common cause of performance problems is accidentally running the same code more than once. The Allocations tool can be a good way to notice. For example, even if the extra objects aren't getting leaked, you might say, "Why did I make 3 of that object? there should only have ever been one!" – Ken Aspeslagh Feb 24 '12 at 17:33
  • @KenAspeslagh - so I'm a bit confused... Let's take an example. I see in the allocations: no more than 200KB at once, but almost 200MB in the Overall Bytes. Does that mean my app takes too much and will get memory warning? or because the Live is only 200KB I'm good to go? – Lior Frenkel May 11 '12 at 11:45
  • 2
    Live bytes is how much memory your app is currently using. The Overall is just a total of all the allocations your app has made (including memory that has since been freed.) – Ken Aspeslagh May 11 '12 at 16:33
  • Hi @KenAspeslagh So if my app has 2 mb of living byts but have 300 mb of overall bytes is, this mean it's ok or I have to optimize this? – NTTake Jul 12 '12 at 19:24
  • It only makes sense to look at overall bytes over a certain period of time of your app running. If you select a certain segment of the timeline, you can see the bytes from that period of time. If an app is making an excessive amount of allocations, even if they aren't leaking, it is going to slow things down. It's good place to start when trying to get an app to be faster. – Ken Aspeslagh Jul 13 '12 at 20:08
  • 1
    @KenAspeslagh why would I care about the overall bytes, if it contains also released objects? – Dejell Mar 21 '13 at 12:21
  • 3
    If you are tuning for performance, then you want to minimize the number of allocations your app makes as it runs (even if you're not leaking said allocations.) Excessive allocations can often be an indicator that you're doing it wrong. – Ken Aspeslagh Mar 22 '13 at 14:28
18

Stats explanation from apple docs. Link to the document

enter image description here

enter image description here

Pranav Jaiswal
  • 3,752
  • 3
  • 32
  • 50