[Mono-bugs] [Bug 77146][Nor] Changed - DynamicMethods leak memory

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Jun 12 20:21:48 EDT 2007


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 robertj at gmx.net.

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

--- shadow/77146	2007-06-12 19:56:31.000000000 -0400
+++ shadow/77146.tmp.5448	2007-06-12 20:21:48.000000000 -0400
@@ -122,6 +122,44 @@
 		g.Emit (OpCodes.Ldc_I4, value);
 		g.Emit (OpCodes.Ret);
 		return (SimpleMethod) d.CreateDelegate (typeof (SimpleMethod));
 	}
 }
 
+
+------- Additional Comments From robertj at gmx.net  2007-06-12 20:21 -------
+I guess I know why:
+
+The icall CreateDelegate_internal doesn't store the MethodInfo
+in delegate's instance. I first thought this is because
+mono_delegate_ctor is doing it anyway, but it doesn't it
+correctly:
+
+void
+mono_delegate_ctor (...)
+{
+
+...
+
+        if ((ji = mono_jit_info_table_find (domain,
+mono_get_addr_from_ftnptr (addr)))) {
+                method = ji->method;
+
+This object is not the original MethodInfo.
+It's another one, just cooked by mono_method_get_object:
+
+                MONO_OBJECT_SETREF (delegate, method_info,
+mono_method_get_object (domain, method, NULL));
+        }
+
+
+This basically means that:
+
+MethodInfo mi;
+Delegate d = Delegate.CreateDelegate (someType, mi);
+Object.ReferenceEquals (mi, d.Method) == false;
+
+but it should be "true", IMO.
+
+Doesn anyone remember why the MethodInfo that was passed
+to CreateDelegate is thrown away?
+


More information about the mono-bugs mailing list