Bug 5181 - Inconsistent finalization behavior when popping UIViewController
Summary: Inconsistent finalization behavior when popping UIViewController
Status: RESOLVED DUPLICATE of bug 1889
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime (show other bugs)
Version: 5.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-05-18 16:59 UTC by Tobias Skarman
Modified: 2012-05-18 17:16 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 1889

Description Tobias Skarman 2012-05-18 16:59:24 UTC
A popped UIViewController's finalizer will not get called before the next PushViewController() call on the same UINavigationController.

If however PopViewControllerAnimated() is overridden in this fashion

        public override UIViewController PopViewControllerAnimated(bool animated)
        {
            return base.PopViewControllerAnimated(animated);
        }

a UIViewController's finalizer is called immediately after a 'pop'

First, I put it off as random GC behavior. But the behavior is consistent.

(1) overriden PopViewControllerAnimated: immediate finalization
(2) no overriden PopViewControllerAnimated: finalization after an arbitrary number of 'pop's and then one 'push'

Not sure if this is a bug. But the expected behavior in both cases would be that in (1) seeing how it seems to be possible to force it. It makes dealing with memory release that much easier and intuitive.

Please advise if I can rely on any of the behaviors
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-05-18 17:16:51 UTC
This is because managed code keeps a cache of the current view controllers, which is only updated when you push a new view controller (since no managed code is usually executed when a view controller is pushed, unless you override PopViewControllerAnimated - and then the cache is updated for pops too).

In any case this has already been filed as bug #1889.

*** This bug has been marked as a duplicate of bug 1889 ***