Bug 605247 - GLib.Timeout leaks memory
Summary: GLib.Timeout leaks memory
Status: RESOLVED DUPLICATE of bug 605295
Alias: None
Product: gtk#
Classification: Mono
Component: gtk-sharp (show other bugs)
Version: 2.x
Hardware: Other openSUSE 11.2
: P5 - None : Major
Target Milestone: ---
Assignee: Gtk# Bugs List
QA Contact: Gtk# Bugs List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-12 16:54 UTC by Mike Krueger
Modified: 2010-05-17 08:04 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Krueger 2010-05-12 16:54:56 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);
	}
}
Comment 1 Alan McGovern 2010-05-12 22:17:40 UTC
The first testcase leaks under 2.6.4 and also mono r156824. The second testcase leaks under neither. Possibly related to bug #605295
Comment 2 Mike Krueger 2010-05-17 08:04:20 UTC
Yes it's the same.

*** This bug has been marked as a duplicate of bug 605295 ***