Re: Memory problems with gdk_pixbuf



John Coppens wrote:
Hello people.

A few weeks ago I posted a message about memory leaking. I haven't solved
the problem yet (thanks for a few privately received suggestions though).

The example below is taken largely from the GGAD manual, but, if the
segment is called repeatedly, allocates large chunks of memory, until a
certain point, where things break ('process killed')

--------------
global variable    GnomeCanvasItem *img_item = NULL;
--------------
  pxb = gdk_pixbuf_new_from_file(path, &err);

// Check if the image was previously allocated. If so, destroy it
// Note that this relies on the pxb being destroyed too. It seems
// this does _not_ happen (Valgrind indicate this)

  if (img_item)
    gtk_object_destroy(GTK_OBJECT(img_item));

  img_item = gnome_canvas_item_new(root,
                gnome_canvas_pixbuf_get_type(),
                "pixbuf", pxb,
                "x", 0.0, "y", 0.0,
                "width", pxb_w, "height", pxb_h,
                NULL);
  gdk_pixbuf_unref(pxb);
--------------
My question is, what is the mechanism to destroy canvas items so that all
resources are freed too. (The above is derived from example in the GGAD, I
believe). Do I have to free the pxb manually?

You could try:

(gdb) watch ((GObject *)pxb)->ref_count

and see if you can find a reference leek, maybe the
canvas item isn't releasing its reference when it gets
destroyed ? maybe there is a reference leek somewhere else ?

Cheers,
                      -Tristan





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]