Re: release check
Re: release check
- Subject: Re: release check
- From: Chris Hanson <email@hidden>
- Date: Wed, 14 Mar 2007 15:15:25 -0700
On Mar 14, 2007, at 2:26 PM, I. Savant wrote:
On Mar 14, 2007, at 5:19 PM, Ahmet Taha Sakar wrote:
Is there a way to check right before program terminate to see if I
have
forgotten to release any variables. I am curious about this, so I
can go
and figure out where they should be released and add release code.
That would be utterly unnecessary as *all* application resources
are reclaimed by the system when the application terminates.
I believe Ahmet was asking about how to check an application for leaks
as it was about to exit, not how to perform extra releases at exit.
Detecting leaks at exit is fairly easy on Mac OS X.
1. Set up an executable for your application that has the following
malloc(3) environment variables set:
MallocStackLogging=1
MallocScribble=1
MallocPreScribble=1
You can see what these environment variables do in the malloc(3) man
page.
2. Set a breakpoint on _exit (underscore included), which is the
underlying API invoked to exit a process. See the _exit(2) man page
for details. Setting this breakpoint will let you catch your
application at a point where it should be completely 100% done (with
the possible exception of detached threads).
3. Run your application and do stuff, and then quit it. You should
hit the breakpoint from #2.
4. While your application is stopped in the debugger, use the
leaks(1) and heap(1) command-line tools to inspect your application's
memory after it has run for leaked objects.
You can also use other performance tools such as ObjectAlloc.app and
MallocDebug.app to track your application's memory behavior; see their
documentation for details on their use.
-- Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden