[Gtk-sharp-list] Gtk.Application.Invoke + anonymous delegates == lots of uints?

32bitkid jim at 32bitkid.com
Fri Dec 8 11:33:03 EST 2006


 
I seem to be getting a weird allocation of uints when using
Gtk.Application.Invoke
 
If i run the following code through heap-buddy:

using System;
using Gtk;
using System.Threading;
 
public class MainWindow : Gtk.Window
{
	Gtk.Label Label1;
	
	public MainWindow() : base ("Test")
	{
		this.DeleteEvent += new DeleteEventHandler(OnDeleteEvent);
		
		Label1 = new Gtk.Label("");
		this.Add(Label1);
		this.ShowAll();
		
		Thread x = new Thread(new ThreadStart(test));
		x.IsBackground = true;
		x.Start();
	}
	
	int ctr = 0;
	
	void test()
	{
		while(true)
		{
			Gtk.Application.Invoke( delegate {
				ctr++;
				Label1.Text = ctr.ToString();
			});
			Thread.Sleep(10);
		}
	}
	
	protected void OnDeleteEvent( object sender, DeleteEventArgs e)
	{
		Application.Quit();
		e.RetVal = true;
	}
}

 
I'll get a lot of uints allocated on the heap. Most seem to be cleaned up by
the garbage collection, but still it doesnt seem quite right. Here is the
output from heap-buddy, after running for about 5 seconds:

$ heap-buddy types 10 sorted by count

            Type                #   Total AvSz AvAge  BT#
                        uint 557439  6.4M 12.0   0.0 18337
                      string  18558  863k 47.6   0.6 18418
                      byte[]  18400  357k 19.9   0.0 18400
         GLib.TimeoutHandler  18392  718k 40.0   0.6     4
   GLib.Timeout/TimeoutProxy   9196  143k 16.0   0.8     2
         System.EventHandler   9196  359k 40.0   0.6     2
    Gtk.Application/InvokeCB   9195  179k 20.0   0.6     1
                    object[]   9186  717k 80.0   0.0  9186
System.Collections.ArrayList   9182  179k 20.0   0.0  9182
   System.Text.StringBuilder   9179  215k 24.0   0.0  9179


Is this a bug, or am I just doing something very wrong. That just seems like
a LOT of uints.

This is basically a stub from another Gtk# program I'm working on that is
fairly thread intestive. I don't remember seeing this kind of behavior
before 1.2. I am running mono 1.2.2, on Fedora Core 5.

Any help would be greatly appriciated. Thanks
-- 
View this message in context: http://www.nabble.com/Gtk.Application.Invoke-%2B-anonymous-delegates--%3D%3D-lots-of-uints--tf2781599.html#a7760598
Sent from the Mono - Gtk# mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20061208/0ec5f018/attachment.html 


More information about the Gtk-sharp-list mailing list