Re: ARC problems
Re: ARC problems
- Subject: Re: ARC problems
- From: Alex Zavatone via Cocoa-dev <email@hidden>
- Date: Tue, 3 Sep 2019 17:41:59 -0500
Is it possible to switch out the view controller that i disappearing with
another one and see if that also disappears?
Is that view controller voiding its own self reference?
> On Sep 3, 2019, at 5:18 PM, Turtle Creek Software via Cocoa-dev
> <email@hidden> wrote:
>
> The app delegate is NOT being deallocated prematurely- we have a breakpoint
> there to check.
>
> We don't allocate the app delegate explicitly, so I had to set a breakpoint
> in init() to see when it happens.
> It's created in main() via NSApplicationMain. Presumably its end of scope
> would be when main ends.
> The MainMenu.xib includes a Delegate object for our GSAppDelegate class, so
> it must be allocated
> via the nib-loading process (the stack trace says InitWithCoder).
>
> GSAppDelegate has strong references to 4 window controller members: main
> window, prefs window, and a couple of log windows.
> But that alone has not kept the main window controller alive. We haven't
> tested the others.
>
> The main window controller that was mysteriously dying used to have a
> strong reference back to the app delegate.
> Whether strong, weak or non-existent, it didn't make any difference. I
> suppose we could add a strong ref somewhere else
> just to be double safe, but I'm not sure where else would make sense.
>
> The startup code was created 3 years ago when we were new to Cocoa,
> probably from one of the HIllegass books.
> It may have flaws, but the app has been running OK otherwise. The problems
> only started when we read about circular references
> and started making up-references __weak.
>
> BTW the Clang specs for ARC mention that it's not exception-safe. If I
> understand correctly,
> strong references will leak, and weak references are released. We don't
> throw any Cocoa exceptions but
> maybe the system does.
>
> Casey McDermott
>
> On Tue, Sep 3, 2019 at 4:24 PM Jean-Daniel <email@hidden> wrote:
>
>>
>>> Le 3 sept. 2019 à 02:33, Turtle Creek Software via Cocoa-dev <
>> email@hidden> a écrit :
>>>
>>> Thanks for all the suggestions for the problems we had with a controller
>>> being
>>> deallocated unexpectedly under ARC. Unfortunately, none of them fixed
>> it.
>>>
>>> We do need to get back to regular app programming, so it will just stay a
>>> mystery.
>>> I was hoping we were doing something obviously dumb, but I guess the bug
>> is
>>> more subtle.
>>>
>>> The app runs OK with the old code with multiple strong references to it
>>> They are circular references, but that controller sticks around for the
>>> full app lifetime. Presumably any leakage
>>> won't happen until late in the game, anyhow.
>>>
>>> Thanks,
>>
>> Just a last suggestion. How is you App delegate created ? Do you keep a
>> strong ref on it. Else it will be deallocated and so will the controller.
>>
>>
> _______________________________________________
>
> 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
_______________________________________________
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: | |
| >ARC problems (From: Turtle Creek Software via Cocoa-dev <email@hidden>) |
| >Re: ARC problems (From: Jean-Daniel via Cocoa-dev <email@hidden>) |
| >Re: ARC problems (From: Turtle Creek Software via Cocoa-dev <email@hidden>) |