• 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: NSWindowController subclasses, and retain cycles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSWindowController subclasses, and retain cycles


  • Subject: Re: NSWindowController subclasses, and retain cycles
  • From: Kyle Sluder <email@hidden>
  • Date: Thu, 24 May 2012 11:27:40 -0400

On May 24, 2012, at 10:26 AM, Jonathan Taylor <email@hidden> wrote:

> I have been battling a retain cycle for a couple of hours, assuming I am at fault, but I am starting to think there is something fishy going on. Can anybody advise?
>
> - I have a window controller subclass (and associated window) A, and a separate window controller subclass (and associated window) B. B contains a property, designated 'retain', that keeps a pointer to A. B is programatically closed first, and later on A is programatically closed
> - I believe that I am correctly balancing retain/release for A.
> - I believe I am doing the same for B.

Please post your code.

>
> 1. If I do not set B's pointer to A, both A and B are deallocated correctly
> 2. If instead I set B's pointer to A, but reset it to nil just before B is closed, both A and B are deallocated correctly
> 3. If instead B still has a live pointer to A when B is closed, this should be autoreleased by the runtime, which it is. However, A never gets deallocated.

If A somehow has a chain of retains that keeps B alive, #3 is wrong. Your approach with #2 seems sensible.

>
> There appears to be some weird runtime voodoo behind the scenes involving NSAutounbinder, which I think is what should ultimately be sending the final release to A. That is what sends the final release to B, but that final release for A is missing under that third scenario above.

It sounds like you're (erroneously) associating an autorelease coming from some framework code with a retain that you're performing yourself.

>

--Kyle Sluder
_______________________________________________

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: NSWindowController subclasses, and retain cycles
      • From: Jonathan Taylor <email@hidden>
References: 
 >NSWindowController subclasses, and retain cycles (From: Jonathan Taylor <email@hidden>)

  • Prev by Date: Re: Arc and autorelease
  • Next by Date: Re: stringWithFormat / Rendering Text (iOS)
  • Previous by thread: Re: NSWindowController subclasses, and retain cycles
  • Next by thread: Re: NSWindowController subclasses, and retain cycles
  • Index(es):
    • Date
    • Thread