1

I'm fairly new to xcode. Just completed my first iPhone app. I've used the Leaks view & found no issues. Now I'd like to do one extra level of checking by observing the number of bytes allocated but not deallocated after various operations.

I see answers like the one below referring to the 'net bytes' column in the Instruments Allocations view being the correct metric.

Checking memory allocation in Instruments

Unfortunately in Instruments / Xcode 4 I don't have this column & it doesn't appear to be available when right clicking on the column headers.

Can someone tell me how to see the 'net bytes' column or equivalent?

Thanks.

Community
  • 1
  • 1
Jonathan
  • 1,327
  • 3
  • 15
  • 24

1 Answers1

2

The equivalent of 'net bytes' is 'live bytes'. This shows you how much memory your app is using right now. For the other columns:

  • #living: Shows you how many objects are allocated right now
  • #transitory: Shows you how many objects where allocated and then deallocated
  • #overall: Is the sum of '#living' and '#transitory'
  • Overall bytes: The sum of memory which would be used, if all '#overall' objects where still allocated.

It is important to not only to reduce the 'live bytes' but also the 'overall bytes' since to much allocations will slow your app down eventually.

One more hint: If you want to check whether a specific operation leaks memory, use the 'mark heapshot' button on the left. It will narrow down the displayed memory usage to what changed in your memory, after you clicked the button. So to check for leaks do the following:

  • A: Start your app and bring to a state x
  • B: Press 'Mark heapshot'
  • C: Performe the actions you suspect to leak memory
  • D: Bring your app to state x again and go to B

Do this several times, to make sure a growing heap is caused by memory leaks and not just by warming caches.

Also, have a look at last years WWDC videos, especially 'Session 311 - Advanced Memory Analysis with Instruments' should be of interest to you.

Philipp Schlösser
  • 5,179
  • 2
  • 38
  • 52
  • Thanks for the thorough explanation Phlibbo, with your help I've been able to confirm there are no memory leaks. Now for submission :) – Jonathan May 27 '11 at 17:28
  • Entirely random, but I meant to upvote this answer and somehow clicked the downvote button :( I can't change my vote now, can the mods do anything about that? – kevlar Feb 15 '13 at 00:49