Archive for January 31st, 2011


Heapshot Analysis

This post wins the award for Best Walkthrough of Using Instruments EVAR — step by step details on how to track down those Really, Really Hard To Find memory leaks too subtle for the analyzer to pick up on:

When is a Leak not a Leak? Using Heapshot Analysis to Find Undesirable Memory Growth

The “Heap Growth” and “Still Alive” columns provide a summation of all of the objects in that heapshot that still exist in all subsequent samplings of the heap. That is, in Heapshot 3, there were 36.08K of allocations spread across 260 allocation events that continued to exist throughout the rest of the run…

… Not only can we expand any given Heapshot iteration to see the inventory of permanent objects allocated in that iteration, but we can dive all the way down to the individual allocations and see a backtrace of exactly where it was allocated.

Turn on Record reference counts in the Allocations instrument. When the app isn’t running, hit the little (i) in the Allocations track in Instruments and click the check box. Then run the application and do the same set of samples (or turn this on from the beginning if you didn’t forget like I did).

Now, when you click through any allocation, you’ll see a list of events that includes the point of allocation and all subsequent retain/release events…

Read the whole thing!