Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS allocations - persistent count in heapshots not always 0

While profiling my iOS app I perform a simple task multiple times where I push and pop a view from the stack, and then take a heapshot. The same code is executed each time and the pushed view just contains some images which get removed as soon as the view gets popped.

screenshot of instruments

Now because the persistent count is 0 for almost half of the heapshots, would it be safe to assume there is no abandoned memory?

I've heard that the rows with a persistent count greater than zero could be because of some internal caching.

I am using Xcode 4.2.1 and the app is using ARC.

Edit:

Thanks to Kendall Helmstetter Gelner I've managed to debug this problem further. I probably shouldn't have been using the simulator for debugging this. I've now run it on the device and it now looks like there is one object which isn't getting released:

Heapshots of app running on device

After looking through the extended detail view I think I've just about found the cause of the problem.

like image 713
RohinNZ Avatar asked Feb 03 '12 04:02

RohinNZ


1 Answers

It's hard to say from just that screenshot what might be cached or not - UIImage will cache things, possibly some other system elements too. It looks like you might be running that in the simulator, have you tried heapshot on a device?

You could also select "Hide System Libraries" to the side and get a better idea how much of your own code is involved.

like image 132
Kendall Helmstetter Gelner Avatar answered Nov 01 '22 00:11

Kendall Helmstetter Gelner