Re: A question of memory management style
Re: A question of memory management style
- Subject: Re: A question of memory management style
- From: vincent habchi <email@hidden>
- Date: Mon, 18 Jul 2011 08:19:02 +0200
Hi!
> In the document object, I am observing such an event, then creating a handler and calling it. I have handled creation either by explicit allocation such as [[HandlerClass alloc] initWith...] or by writing a class method to create an object like [HandlerClass createHandlerWith...]. I then call the appropriate action method like [handlerObject beginProcesssing...] and return to the event loop. The handler class handles interactions, and releases itself when it is done. This does not result in leaks, but the analyzer warns me that the handler is potentially leaking from the document class.
The analyzer is right in terms of object graph. If you consider your call to -init as an initial ownership of your document on the handler, then it is the owner which must relinquish its ownership, and not the object owned.
In your case, I’d recommend, even if it seems artificial, that the handler, when done, informs the document object through a callback which releases it. This way, the analyzer won’t protest, and the code is neater and future proof.
Vincent_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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