[Gtk-sharp-list] Gtk.Application.Invoke + anonymous delegates == lots of uints?
Rafael Teixeira
monoman at gmail.com
Sat Dec 9 08:07:47 EST 2006
It is worse: If heap-buddy is showing them up and GC collects them, it
means they are boxed uints (probaly autoboxed ones), what means a lot
of overhead creating/managing objects around the value type, beyond
the memory comsuption.
Definitively we need to find the culprit, probably someone passing a
uint to some method that wants an object. Can you help to better
assess where it could be?
Thanks,
On 12/8/06, 32bitkid <jim at 32bitkid.com> wrote:
> 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: Gtk.Application.Invoke + anonymous delegates
> == lots of uints?
> Sent from the Mono - Gtk# mailing list archive at Nabble.com.
>
> _______________________________________________
> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
>
>
--
Rafael "Monoman" Teixeira
---------------------------------------
"The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man." George Bernard Shaw
More information about the Gtk-sharp-list
mailing list