Search code examples
objective-cxcodexcode-instruments

Why does allocations graph in instruments show no increase yet marked generations show memory growth


I am testing memory issues in allocations instruments and something seems strange. Allocations graph, shown in blue, shows no increase (even you can see little decrease -- look at the red markers) but you can see memory growth in generation snapshots. Why is it inconsistent?

enter image description here


Solution

    1. Your generations are growing by 87-123kb, but that's visually indiscernible on an allocations chart, whose peak looks like it must have been 15mb or so.

    2. If you look at those valleys where you marked your generations, it looks like they're lower, but if you look at your image carefully in a photo editing tool (draw a horizontal line), they're really not.

    3. Even if they were lower, the generations tool will show you items that were allocated but not released. It does not net out those items that we deallocated in the process, too.

      enter image description here

      Look at generation C, which in this case really is much lower, but the "growth" is just showing us what objects that were allocated but not released between generation B and C.