Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Instruments' Allocation tool misses quite a bit

My app has been crashing a lot, for reasons that I'm struggling to understand. It's not so much that it's crashing -- it's getting killed by an outside "Unknown" process:

Processes
     Name        <UUID>       rpages       recent_max       [reason]          (state)

     test-app    <....>       167111       167111     [per-process-limit] (frontmost) (resume)

I could understand that if I were allocating a huge block of memory, or a zillion smaller blocks, but I'm not doing anything that outrageous. Profiling with Instruments tells me that the app uses only around 8 MB, occasionally spiking up to 13 MB or so when I load some large content. There are no egregious leaks, and the app is often killed very quickly.

A colleague started using Activity Monitory to check the app's memory usage while running in the simulator and noticed that memory spiked from around 70 MB (I guess things are a little different in the simulator) to upward of 800 MB when we start using a certain library. So, I started profiling in the simulator instead of on the device. The Allocations tool continues to report that the app uses 8-ish MB, but the VM Tracker tells another story:

Instruments screen shot

So... it looks like VM Tracker is able to see some significant memory use that Allocations isn't.

Why is the Allocations tool missing 99% of the memory this app is using?

Update: In response to nielsbot's question, I took a closer look at the VM Tracker's info and found that the largest part of the memory that I'm not seeing in Allocations is attributed to Core Animation:

VM Tracker screenshot

like image 549
Caleb Avatar asked Mar 20 '13 23:03

Caleb


1 Answers

I think VM space includes things like shared frameworks and mapped memory whereas allocations may not...

I guess resident size is closer to the actual amount of RAM used. Pure VM memory could just be mapped address space, not actual physical RAM consumed.

For example, looking at Safari, I see 1.92 GB virtual memory mapped, but closer to 549 MB resident, which I think makes sense... enter image description here

like image 189
nielsbot Avatar answered Oct 15 '22 01:10

nielsbot