Bugzilla – Bug 605247
GLib.Timeout leaks memory
Last modified: 2010-05-17 08:04:20 UTC
This program leaks memory: class Test { static bool Timeout() { Console.WriteLine ("TIMEOUT "); return false; } static GLib.TimeoutHandler handler = Timeout; public static void Main (string[] args) { Gtk.Application.Init (); do { uint timer = GLib.Timeout.Add (650, handler); GLib.Source.Remove (timer); System.GC.Collect (); } while (true); } } This one doesn't: class Test { static bool Timeout() { Console.WriteLine ("TIMEOUT "); return false; } static GLib.TimeoutHandler handler = Timeout; public static void Main (string[] args) { Gtk.Application.Init (); do { uint timer = GlibTimer.Add (650, handler); GlibTimer.Remove (timer); System.GC.Collect (); } while (true); } class GlibTimer { public delegate bool TimeoutHandler (); public static uint Add (uint timeOut, TimeoutHandler handler) { return g_timeout_add (timeOut, handler, IntPtr.Zero); } public static void Remove (uint id) { g_source_remove (id); } [DllImport("libglib-2.0.so")] static extern void g_source_remove (uint id); [DllImport("libglib-2.0.so")] static extern uint g_timeout_add (uint id, TimeoutHandler function, IntPtr data); } }
The first testcase leaks under 2.6.4 and also mono r156824. The second testcase leaks under neither. Possibly related to bug #605295
Yes it's the same. *** This bug has been marked as a duplicate of bug 605295 ***