GNOME Bugzilla – Bug 352264
gtk_status_icon_set_from_pixbuf leaks the old pixbuf
Last modified: 2006-08-29 06:03:10 UTC
For some reason, gnome-typing-monitor is leaking like mad: $ pmap -x 12262 12262: gnome-typing-monitor Address Kbytes RSS Anon Locked Mode Mapping 08048000 28 - - - r-x-- gnome-typing-monitor 0804f000 4 - - - rw--- gnome-typing-monitor 08050000 67968 - - - rw--- [ anon ] ... I'll have a poke to see if this is anything obvious.
==25211== 1,720,152 (70,200 direct, 1,649,952 indirect) bytes in 1,350 blocks are definitely lost in loss record 5,156 of 5,156 ==25211== at 0x40212CD: malloc (vg_replace_malloc.c:149) ==25211== by 0x498014F: g_malloc (in /usr/lib/libglib-2.0.so.0.1200.2) ==25211== by 0x498FA38: g_slice_alloc (in /usr/lib/libglib-2.0.so.0.1200.2) ==25211== by 0x498FDDD: g_slice_alloc0 (in /usr/lib/libglib-2.0.so.0.1200.2) ==25211== by 0x48BD015: g_type_create_instance (in /usr/lib/libgobject-2.0.so.0.1200.2) ==25211== by 0x48A42C0: (within /usr/lib/libgobject-2.0.so.0.1200.2) ==25211== by 0x48A288D: g_object_newv (in /usr/lib/libgobject-2.0.so.0.1200.2) ==25211== by 0x48A33C6: g_object_new_valist (in /usr/lib/libgobject-2.0.so.0.1200.2) ==25211== by 0x48A34C6: g_object_new (in /usr/lib/libgobject-2.0.so.0.1200.2) ==25211== by 0x46A2CB3: gdk_pixbuf_new_from_data (in /usr/lib/libgdk_pixbuf-2.0.so.0.1000.2) ==25211== by 0x46A100E: gdk_pixbuf_copy (in /usr/lib/libgdk_pixbuf-2.0.so.0.1000.2) ==25211== by 0x804B931: update_icon (drwright.c:160)
Looks like it was introduced in the recent changes to gtkstatusicon? It's never leaked like that before :) If someone that actually has a 2.15 environment setup could take a look, that would be great.
Yeah, looks like GtkStatusIcon is leaking the pixbuf. gtk_status_icon_set_from_pixbuf() takes a reference on the pixbuf, but at no point is the old reference dropped. Looks like a thinko in reset_image_data: static void gtk_status_icon_reset_image_data (GtkStatusIcon *status_icon) { GtkStatusIconPrivate *priv = status_icon->priv; priv->storage_type = GTK_IMAGE_EMPTY; g_object_notify (G_OBJECT (status_icon), "storage-type"); switch (priv->storage_type) { case GTK_IMAGE_PIXBUF: if (priv->image_data.pixbuf) g_object_unref (priv->image_data.pixbuf); priv->image_data.pixbuf = NULL; g_object_notify (G_OBJECT (status_icon), "pixbuf"); break; case GTK_IMAGE_STOCK: g_free (priv->image_data.stock_id); priv->image_data.stock_id = NULL; g_object_notify (G_OBJECT (status_icon), "stock"); break; case GTK_IMAGE_ICON_NAME: g_free (priv->image_data.icon_name); priv->image_data.icon_name = NULL; g_object_notify (G_OBJECT (status_icon), "icon-name"); break; case GTK_IMAGE_EMPTY: break; default: g_assert_not_reached (); break; } } Changing storage_type to EMPTY after checking it would probably be a better idea. :)
Created attachment 71370 [details] [review] Fix This patch fixes the leak for me.
2006-08-26 Matthias Clasen <mclasen@redhat.com> * gtk/gtkstatusicon.c (gtk_status_icon_reset_image_data): Don't leak pixbufs. (#352264, Ross Burton)
*** Bug 353333 has been marked as a duplicate of this bug. ***