[Gtk-sharp-list] Gtk.Image.Pixbuf memory leak

Jason Smith jassmith at gmail.com
Mon Aug 4 11:08:39 EDT 2008


The following code, which I use purely for demostration, produces a
memory leak of the entire pixbuf that I load into a Gtk.Image.

protected virtual void OnButton1Clicked (object sender, System.EventArgs
e)
{
	Gdk.Pixbuf pixbuf = IconTheme.Default.LoadIcon
(IconTheme.Default.ListIcons (null)[x], 256, 0);
	image2.Pixbuf = pixbuf;
	pixbuf.Dispose ();
	x++;
}

image2 is a Gtk.Image.  I tied the method to the pushing of a button and
pressed it a lot.  After pressing it 20 or 30 times, my memory usage had
gone from 3MB to 20MB.

I use similar code to this inside of GNOME Do.  The application works,
but it seems to leak pixbufs.  Unfortunately for GNOME Do, this is a LOT
of pixbufs.  CellRendererPixbufs seem to have the same issue, but its to
a smaller degree for us since those are tiny pixbufs.



More information about the Gtk-sharp-list mailing list