On May 24, 2012, at 10:21 AM, Fritz Anderson wrote: > On 24 May 2012, at 9:26 AM, Jonathan Taylor wrote: > >> - 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. >> >> 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. > > Why do you believe that a retain @property does not always require a release > (set to nil)? The autorelease you seem to have detected was sent by a > completely different chain of execution to balance a retain made in that > chain. The operating system does not magically know that you're done with B's > retention of A; you have to balance your own retains with your own releases. > (2) works because it is correct.
It’s ambiguous from the original post, but since he only points out that A never gets deallocated, my assumption is that B *does* get deallocated. If this is the case, A should get released in B’s dealloc method (unless he’s not using ARC and forgot to do this). Charles _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com