Memory leak problem



Hi all.

Please check this code fragment:

  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);

The above fragment is called regularly, and the pxb's eat up the memory
this way...

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?

Thanks in advance
John



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