Bug 245 - GC Prematurely collecting instances
Summary: GC Prematurely collecting instances
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 1.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
: 211 ()
Depends on:
Reported: 2011-08-09 13:07 UTC by Jonathan Pryor
Modified: 2011-08-19 20:12 UTC (History)
3 users (show)

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

ScratchThreadUiUpdate.zip (13.14 KB, application/zip)
2011-08-09 13:07 UTC, Jonathan Pryor

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:

Description Jonathan Pryor 2011-08-09 13:07:38 UTC
Created attachment 97 [details]

This is a possible simplification of the NullReferenceException mentioned in  Bug #230, Comment #1. Unfortunately, this doesn't generate a NullReferenceException.

 1. Download and extract ScratchThreadUiUpdate.zip
 2. Build, Install, and Run the project.

Expected results:

A never ending stream of numbers to `adb logcat` and to the screen.

Actual results:

It exits nearly immediately. The following is visible on `adb logcat`:

I/ActivityManager(   96): Start proc ScratchThreadUiUpdate.ScratchThreadUiUpdate for activity ScratchThreadUiUpdate.ScratchThreadUiUpdate/scratchthreaduiupdate.Activity1: pid=13425 uid=10072 gids={3003}
I/ActivityThread(13425): Pub ScratchThreadUiUpdate.ScratchThreadUiUpdate.__mono_init__: mono.MonoRuntimeProvider
D/dalvikvm(13425): Trying to load lib /data/data/ScratchThreadUiUpdate.ScratchThreadUiUpdate/lib/libmonodroid.so 0x40513f38
D/dalvikvm(13425): Added shared lib /data/data/ScratchThreadUiUpdate.ScratchThreadUiUpdate/lib/libmonodroid.so 0x40513f38
D/dalvikvm(13425): GC_CONCURRENT freed 1222K, 55% free 3088K/6727K, external 1625K/2137K, paused 3ms+2ms
D/dalvikvm(13425): GC_CONCURRENT freed 453K, 52% free 3238K/6727K, external 1625K/2137K, paused 2ms+11ms
I/ActivityManager(   96): Displayed ScratchThreadUiUpdate.ScratchThreadUiUpdate/scratchthreaduiupdate.Activity1: +2s648ms
D/*jonp*  (13425): Loop: 0
D/dalvikvm(13425): GC_EXPLICIT freed 22K, 52% free 3252K/6727K, external 2002K/2137K, paused 49ms
I/ActivityManager(   96): Process ScratchThreadUiUpdate.ScratchThreadUiUpdate (pid 13425) has died.
E/InputDispatcher(   96): channel '4076c0c0 ScratchThreadUiUpdate.ScratchThreadUiUpdate/scratchthreaduiupdate.Activity1 (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
E/InputDispatcher(   96): channel '4076c0c0 ScratchThreadUiUpdate.ScratchThreadUiUpdate/scratchthreaduiupdate.Activity1 (server)' ~ Channel is unrecoverably broken and will be disposed!
D/Zygote  (   67): Process 13425 exited cleanly (1)
Comment 2 Jonathan Pryor 2011-08-09 13:17:25 UTC
Commenting out the GC.Collect() call within Activity1.Exec() (Activity1.cs:39) allows the program to run as expected, so it appears to be due to objects being prematurely collected by the GC.
Comment 3 Rodrigo Kumpera 2011-08-18 15:13:24 UTC
Fixed in mobile-master in 472b3e6fca11bef16cb489cf8f32c0c4fe872048
Comment 4 Rodrigo Kumpera 2011-08-19 20:12:24 UTC
*** Bug 211 has been marked as a duplicate of this bug. ***