tags:

views:

103

answers:

3

I am wondering is there a way to find out memory allocations that dont get deallocated on iphone application exit or it's termination . I have been using instruments fixed most of leaks that I had in my application, but i am worried that there are still some allocation that i didnt release.

Thanks

+3  A: 

No need to worry about cleaning up memory on application exit. The operating system will wipe out any memory allocated to your application at that point.

Frank Schmitt
That may be so, but that doesn't mean that memory leaks shouldn't be found and fixed; It doesn't mean that those leaks couldn't cause problems while his app is still running. Terminating the app and identifying unreleased resources at termination is the best way I know to find those leaks.
Die in Sente
It's not a good way to find the leaks, because it's far more important to find the leaks caused when the application is being used. It's good to clear out all leaks but there's nothing really compelling about looking in particular for leaks at termination over finding all the other leaks first - in particular if you are after some tricky leak hunting try issuing low memory warnings in various situations, and fix those.
Kendall Helmstetter Gelner
No, really, it is absolutely a total waste of time to fix leaks on application exit. Deallocating memory is a waste of CPU cycles during termination and it is quite likely the system frameworks don't bother.
bbum
@Die in Sente: You're talking actual leaks — things that should have been deallocated during the program's lifetime but weren't. This question is about freeing memory on exit, which is a totally different matter.
Chuck
+4  A: 

In short, don't bother trying to find and fix leaks caused during application termination. It is quite likely -- almost guaranteed -- that neither Cocoa nor the iPhone frameworks try to release all memory on termination as doing so is entirely a waste of CPU cycles.

If you are going to hunt down leaks, do so through using your application as your users do, keeping an eye on the Object Alloc instrument's analysis.

What can be useful, though, is putting a hook in that is triggered before termination is an absolute. Stop there and make sure the app's object graph is as expected.

bbum
+1  A: 

but if you use opengl please clear out your buffers :P.

drunknbass