[Mono-bugs] [Bug 50917][Wis] New - GC.KeepAlive's scope only lasts until it is called.
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Wed, 12 Nov 2003 22:38:31 -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=50917
--- shadow/50917 2003-11-12 22:38:31.000000000 -0500
+++ shadow/50917.tmp.29756 2003-11-12 22:38:31.000000000 -0500
@@ -0,0 +1,64 @@
+Bug#: 50917
+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.KeepAlive's scope only lasts until it is called.
+
+Description of Problem:
+According to msdn:
+
+"This method references obj, making that object ineligible for garbage
+collection from the start of the routine to the point, in execution order,
+where this method is called. Code this method at the end, not the
+beginning, of the range of instructions where obj must be available."
+
+MS follows this contract, we do not...
+
+Steps to reproduce the problem:
+using System;
+
+class Foo {
+ ~Foo () {
+ Console.WriteLine ("DeFOO!");
+ }
+
+ public static void Main() {
+
+ Foo bar = new Foo ();
+ Console.WriteLine ("a");
+ GC.KeepAlive (bar);
+ bar = null;
+
+ Console.WriteLine ("b");
+
+ GC.Collect ();
+ GC.WaitForPendingFinalizers ();
+
+ Console.WriteLine ("c");
+ }
+}
+
+Actual Results:
+a
+b
+c
+DeFOO!
+
+
+Expected Results:
+a
+b
+DeFOO!
+c