Tomas Vana
Tomas Vana

Reputation: 18785

Memory profiling with instruments

I tried to profile an app with Instruments to see how much memory the app is using and whether there are some leaks.

After tweaking it a little bit, I got rid of a couple of leaks and now it's not showing any. However, I noticed that every time I push some view controller and pop it back, the memory goes up, then a little bit down, but not to the level before the push, e.g. Live Bytes showing

The funny thing is, after pushing it second time (or even 10 times) it doesn't increase over the previous value, so although it looks like a leak, it's probably some kind of a cache or something. I first thought it's something specific to my code but then I was able to reproduce it pretty much with any view controller, no matter how simple the content happens to be.

Is there a reasonable explanation for this phenomenon or am I just doing something completely wrong in all the examples that I have built ?

Upvotes: 4

Views: 320

Answers (1)

Cyprian
Cyprian

Reputation: 9453

Thats happens b/c of autorelease pools, and memory that is suppose to be released for you. It stays for as long as it needs. When you push more viewControllers on the stack more autoreleased objects are created. Some of them will be released earlier the others, but it will very in time, so your memory fluctuation is normal.

Upvotes: 3

Related Questions