• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: A question of memory management style
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >A question of memory management style (From: John Brownie <email@hidden>)

  • Prev by Date: Re: A question of memory management style
  • Next by Date: Re: Need help debugging this
  • Previous by thread: Re: A question of memory management style
  • Next by thread: Re: A question of memory management style
  • Index(es):
    • Date
    • Thread