ObjectAlloc tool and framework debugging
ObjectAlloc tool and framework debugging
- Subject: ObjectAlloc tool and framework debugging
- From: Skip Haughay <email@hidden>
- Date: Thu, 23 Nov 2006 18:12:55 -0800
I have been posting the past few days regarding the trials and tribulations of debugging some leaks in a framework on which I am working. To reiterate, I have the code for the framework, and setup a custom executable that launches a little Cocoa front-end application, which then loads the framework and exercises its functionality. From within the debugger, I am able to trace into the framework, set breakpoints, etc.
I am attempting to use the ObjectAlloc tool to track down some memory leaks. From within XCode, in the framework project, I select the option to run using the ObjectAlloc tool. Everything starts up just fine, and I work the portion of the code which generates the leak. I set the tool up to flag retain/release behavior as well as backtraces. Now the problem... When I LOOK at the backtraces from within ObjectAlloc, I see method entry points for stuff in the host Cocoa app, but once it dips into the framework code, I get addresses rather than entry point names. I could just use gdb to resolve the entry point names, but in many cases of these leaks, we are talking call stacks of some 40 items deep, due to the recursive nature of the code being executed. It would be a monumental task to have to wade through each and every one of these, for each and every retain/release action. So my question is, how in the world do I get this to show meaningful call stack information?
When I run the leaks tool, I get all the call stack information for the allocation. I need call stack information for all the memory retain/release/autorelease stuff, so I know where in the code these things are getting touched, in order to better understand the problem that is occurring. This is why I need to get this same symbolic information from within ObjectAlloc. So what am I doing wrong, or how can I setup my environment to do this correctly?
I also have some questions about how ObjectAlloc works. When it works, I see AllocateEvents, RetainEvents, ReleaseEvents, AutoreleaseEvents, and Dealloc Events. When I look at the inspector, I assume that I can click on each of these events for a particular memory object, and see the call stack as to where that particular event was invoked. Am I right about that?
Also, I am curious about what causes the retain and release events... Obviously a call to retain and release will do this. BUT does the initial Alloc generate an allocate event AND a retain event to get the initial reference count of one? Or is the reference count just set to one by the Alloc event? Is the autorelease event registered in ObjectAlloc when the autorelease method is invoked, or is it registered when the pool is cleared? OR does the autorelease event happen when autorelease is invoked, and then when the pool clears, a subsequent release event is registered? If this is the case, is there any way I can tell that this release event was caused by an autorelease action from the pool clearing?
This leak is really proving to be a bear to debug, because of the level of complexity due to the recursion, and the sheer number of data fields being parsed in my code. For a specific class of data fields and chain of events, I either have too few releases, or too many retains.
Thanks for any clarification or suggestions!
Skip Haughay
_______________________________________________
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