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.

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.

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.

I am concerned by the following post:
        http://theocacao.com/document.page/18
This seems to imply there is some dodginess behind the scenes that Apple have 
bodged to try and make things work. The blog post is 8 years old, so I would 
have hoped this would be sorted by now(!), but it does sound remarkably close 
to my scenario here.

I may have missed out some important relevant information here, so let me know 
if I need to be more specific about what I am doing, but can anybody suggest:
- If you agree the problem is likely to be with the runtime rather than with my 
code
- What the best workaround would be (scenario 2 above will probably do as a 
workaround...)
- Whether the fact that I am hitting this suggests I am doing something out of 
the ordinary that I should probably be doing differently.

Thanks for any advice
Jonny
_______________________________________________

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

Reply via email to