1

I am using the Instruments tool to find the Leaks in my application. While checking the Leaks in my application, I am able to see the Allocation tab too.

So far, I never used that allocations tab in the instruments tool. I just checked what it could be and I am able to see the #All Allocations * field. Which shows the Overall Bytes used by the application. I am shocked to see that the size is keep on increasing.

Should I worry about only the Memory leaks not the Allocations? And the #All allocations meant for the current application size or overall application size ?

Cyril
  • 1,216
  • 3
  • 19
  • 40
  • Also check memory monitor as well, http://stackoverflow.com/questions/5518918/instruments-with-ios-why-does-memory-monitor-disagree-with-allocations – iDev Nov 15 '12 at 19:13

2 Answers2

2

The allocations are useful to show your App memory footprint. If you present a modalViewController and dismiss it (and you repeat it), and you see that your Application live bytes keeps increasing, there's something wrong. Memory leaks is useful, to see memory that was allocated and you lost a reference to it. Using ARC helps, but you can still have memory leaks (circular referencing for example). Allocations also helps you understand where memory is allocated and never released. For example a NSArray full of objects, that you are not using, but you are still keeping alive. For your questions:

1) You should worry about both.

2) Live bytes shows your current application size (virtual memory). Overall application size, is exactly what it says: "The total number of allocations in the selected time range".

You can also check this.

Community
  • 1
  • 1
Rui Peres
  • 25,741
  • 9
  • 87
  • 137
  • 1
    Good answer. I just want to add that increasing the live bytes in an app can cause a memory warning and the app could crash, so it is really important to maintain those allocations between some limits to avoid crashing the app. – Miguel Isla Nov 15 '12 at 08:50
  • 1
    The memory warning, from what I have been testing can also be caused, by the amount of (memory needed / time). You can have a live 80mb app without any problem and without any memory issue. But if you have a 1mb app, which suddenly starts to rush to 80mb, it can start popping some warnings. – Rui Peres Nov 15 '12 at 08:53
  • @JackyBoy. Thank you so much. The link which you have provided and your explanation , made me very clear about the Live Bytes and Overall Bytes. – Cyril Nov 15 '12 at 09:30
  • I have one more doubt. I have created a application, where the Overall bytes will cross 80MB not rapidly. As I am presenting different view controllers. If I maintain the Live Bytes, this wont be a problem right ? – Cyril Nov 15 '12 at 09:33
  • 1
    The live bytes should concern you the most, because that's whats live NOW. The overral bytes tells you the quantity of resources your App used since the beginning of the test. – Rui Peres Nov 15 '12 at 09:36
1

The All Allocations line shows the current size of the heap under the Live Bytes column, and the total number of heap bytes ever allocated under the Overall Bytes column. If you allocate a megabyte, both columns will increase by 1 MB. If you then free that megabyte, Live Bytes will decrease by 1 MB but Overall Bytes will not change.

Live Bytes is useful for detecting abandoned or leaked memory.

Overall Bytes is usually not very useful. You might use it when you are having a performance problem and want to see if it's because of excessive allocation churn.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848