[Mono-bugs] [Bug 50916][Wis] New - GC does not see objs put into an array as dead till array's method is out of scope

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 12 Nov 2003 22:30:29 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by bmaurer@users.sf.net.

http://bugzilla.ximian.com/show_bug.cgi?id=50916

--- shadow/50916	2003-11-12 22:30:29.000000000 -0500
+++ shadow/50916.tmp.29658	2003-11-12 22:30:29.000000000 -0500
@@ -0,0 +1,67 @@
+Bug#: 50916
+Product: Mono/Runtime
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: bmaurer@users.sf.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: GC does not see objs put into an array as dead till array's method is out of scope
+
+Description of Problem:
+We do not apply the same rules for reachability to arrays as we do to
+objects that are by themselves. MS does not exhibit this behavior.
+
+Steps to reproduce the problem:
+using System;
+
+class foo {
+	static int count = 0;
+	~foo () {
+		count++;
+	}
+	
+	
+	static void Main ()
+	{
+		blah ();
+		
+		GC.Collect ();
+		GC.WaitForPendingFinalizers ();
+		
+		Console.WriteLine (count);
+	}
+	
+	static void blah ()
+	{
+		object bar = new foo ();
+		foo [] foofoo = new foo [10];
+	
+		for (int i = 0; i < foofoo.Length; i++)
+			foofoo [i] = new foo ();
+		
+		foofoo = null;
+		bar = null;	
+		
+		GC.Collect ();
+		GC.WaitForPendingFinalizers ();
+		Console.WriteLine (count);
+	}
+}
+
+
+Actual Results:
+1
+11
+
+Expected Results:
+11
+11