Bug 6461 - View Controllers are garbage collected on the simulator but not on an iPad device.
Summary: View Controllers are garbage collected on the simulator but not on an iPad de...
Status: RESOLVED FEATURE
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-08-07 23:57 UTC by Jean Coetzee
Modified: 2014-12-03 02:52 UTC (History)
3 users (show)

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


Attachments
Sample app demonstrating View Controllers not being GC (162.30 KB, application/x-zip-compressed)
2012-08-07 23:57 UTC, Jean Coetzee
Details
More complete sample app. (19.81 KB, application/x-zip-compressed)
2012-08-10 00:23 UTC, Jean Coetzee
Details


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 FEATURE

Description Jean Coetzee 2012-08-07 23:57:57 UTC
Created attachment 2325 [details]
Sample app demonstrating View Controllers not being GC

In the attached sample application, the View Controllers are not garbage collected when they call DismissViewController() on themselves on an iPad 1 running iOS 5.0.1.  However, when running on the Simulator, they are.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-08-09 04:58:08 UTC
I tried the app in an iOS 5.1 simulator and device (iPad3), and in both cases the table view is empty. The only thing I can do is to click on th Item button, but nothing happens. Are you sure the sample app you uploaded is the correct one?
Comment 2 Jean Coetzee 2012-08-09 18:14:50 UTC
Yes, sorry.  Should have mentioned that this is a very minimal test case.  Have to have the device in landscape orientation for the left pane of the split view to display. Then select an option from the left pane.
Comment 3 Jean Coetzee 2012-08-09 18:16:01 UTC
Yes, sorry.  Should have mentioned that this is a very minimal test case.  Have
to have the device in landscape orientation for the left pane of the split view
to display. Then select an option from the left pane.
Comment 4 Jean Coetzee 2012-08-10 00:23:13 UTC
Created attachment 2335 [details]
More complete sample app.

A bit more complete example demonstrating the problem.
Comment 5 Rolf Bjarne Kvinge [MSFT] 2012-08-10 12:07:35 UTC
I can now reproduce the behavior, and it is perfectly normal.

The difference is that in the simulator the garbage collector is much more aggressive (executes more frequently) than on device (this is to catch a fairly common type of problem during debugging instead of when the app is running on a user device).

You can test this yourself by making the GC more aggresive, just add this to your Main method:

System.Threading.ThreadPool.QueueUserWorkItem ((v) => {
    while (true) {
        System.Threading.Thread.Sleep (1000);
        GC.Collect (GC.MaxGeneration);
    }
});

and the view controllers will be promptly freed on device too.

As I've mentioned, don't worry about this, it is perfectly normal that objects aren't freed as soon as possible in a garbage collected environment.
Comment 6 Jean Coetzee 2012-08-12 18:26:04 UTC
Thanks for your feedback.  Much appreciated.