After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 352264 - gtk_status_icon_set_from_pixbuf leaks the old pixbuf
gtk_status_icon_set_from_pixbuf leaks the old pixbuf
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.10.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 353333 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-08-21 16:16 UTC by Ross Burton
Modified: 2006-08-29 06:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix (584 bytes, patch)
2006-08-22 14:56 UTC, Ross Burton
none Details | Review

Description Ross Burton 2006-08-21 16:16:45 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.
Comment 1 Ross Burton 2006-08-21 16:55:58 UTC
==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)
Comment 2 Richard Hult 2006-08-21 17:00:13 UTC
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.
Comment 3 Ross Burton 2006-08-21 17:10:30 UTC
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. :)
Comment 4 Ross Burton 2006-08-22 14:56:04 UTC
Created attachment 71370 [details] [review]
Fix

This patch fixes the leak for me.
Comment 5 Matthias Clasen 2006-08-26 06:26:50 UTC
2006-08-26  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkstatusicon.c (gtk_status_icon_reset_image_data): 
	Don't leak pixbufs.  (#352264, Ross Burton)
Comment 6 Richard Hult 2006-08-29 06:03:10 UTC
*** Bug 353333 has been marked as a duplicate of this bug. ***