• 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: Avoiding mutual retain cycles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Avoiding mutual retain cycles


  • Subject: Re: Avoiding mutual retain cycles
  • From: Ken Thomases <email@hidden>
  • Date: Mon, 21 Jul 2008 14:28:47 -0500

On Jul 21, 2008, at 1:50 PM, Markus Spoettl wrote:

By changing the reference from B to A to a weak reference which doesn't retain and release A, the problem goes away. However, generally speaking this is dangerous road to go (and against memory management guidelines)

Actually, it is not against the guidelines, it is in keeping with them.

See here: http://developer.apple.com/documentation/Cocoa/Conceptual/ MemoryMgmt/Concepts/ObjectOwnership.html#//apple_ref/doc/uid/ 20000043-1000698

That explicitly discusses retain cycles and the use of weak references to break them.


For instance, how are delegates implemented in AppKit, are they retained?

There are not retained by virtue of being assigned as a delegate. They are retained by whatever code made the decision to assign them as the delegate. If that code later decides to release the object, it must also unset it as a delegate first.


Cheers,
Ken

_______________________________________________

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


  • Follow-Ups:
    • Re: Avoiding mutual retain cycles
      • From: Markus Spoettl <email@hidden>
References: 
 >Avoiding mutual retain cycles (From: Markus Spoettl <email@hidden>)

  • Prev by Date: Re: Growl, NSTimer, and Launching Application help!
  • Next by Date: Re: Redrawing CALayer subclass when super layer is scaled
  • Previous by thread: Re: Avoiding mutual retain cycles
  • Next by thread: Re: Avoiding mutual retain cycles
  • Index(es):
    • Date
    • Thread