views:

36

answers:

1

I am tracking a very tough memory leak (or more likely abandoned memory) situation. I do the following:

1) start my application
2) get to a point where the application will show the leak
3) start instruments using the 'allocations' choice
4) attach to my process and start recording
5) take an initial heapshot
6) take an initial snapshot with VM tracker
7) reproduce the steps that cause the memory to rise
8) take another heapshot
9) take another snapshot with VM tracker

If I do those steps, I see results that don't really make sense. I am hoping that I am missing some information about how these tools work. For example, I know that the 'leaks' tool doesn't track ALL kinds of memory allocations (carbon apps for example). My application is a huge, legacy app that could have weird allocation code in some out dated subsystem that I am not familiar with. That said, this is what I see:

  • in the initial snapshot of VM tracker when I look at the summary, the type MALLOC_SMALL is fairly small at roughly 72MB (virtual size)
  • in the second snapshot, MALLOC_SMALL usage has grown to 224MB (again virtual size)
  • in the second heapshot, it tells me the heapgrowth is 45MB

So how can MALLOC_SMALL grow from 72MB to 224MB, but the heapgrowth is only 45MB? Is the Allocations instrument missing something that VMTracker is recording?

Further supporting that I am missing something in the Allocations instrument...if I look at the NEW regions listed under MALLOC_SMALL (ones that weren't in the first snapshot, but were in second), those addresses should correspond to pages that were allocated and account for the 72MB->224MB difference, correct? So then, I remembered the range of addresses for that region (eg, 0x79000000-0x7b000000), and go back to the Allocations instrument and sort of the list of 'All Objects' by address. Then I look for addresses in that range. However, I only see 4 allocations that account only for 4KB?! Where are the other 32MB that VM tracker reported in that region?

Any help would be appreciated....I am hoping it is something basic about how these tools work that I am just not understanding.

+1  A: 

Not a direct answer - but Bill Bumgarner recently blogged about some uses of Instruments and memory growth :

http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/

There's some good information in there...

Andrew Kimpton