[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
RE: gtk_image_set_image_from_pixbuf(Pixbuf*) mem leak
- From: martyn 2 russell bt com
- To: zigusinc yahoo com, gtk-app-devel-list gnome org
- Subject: RE: gtk_image_set_image_from_pixbuf(Pixbuf*) mem leak
- Date: Fri, 2 May 2003 08:16:18 +0100
> I'm writing a game with Gtk v2.0. For the gameplay I
> have a table of 3 layers of pictures I have to update
> once in a while. If I use
> gtk_image_set_image_from_pixbuf(Pixbuf*) gtk doesn't
> seem to take care of deallocating the memory allocated
> by the old pixbuf. Is there any way I can do that
> myself?
GTK should do free memory it owns. If you have used a pixbuf that you
loaded in from a file, you have a reference count of 1 on it and it is up to
you to free it. For example,
GdkPixbuf *pb = NULL;
pb = (...) /* load from file */
gtk_image_set_image_from_pixbuf(GTK_IMAGE(myimage), pb);
/* YOU MUST UNREF THE PIXBUF */
g_object_unref(G_OBJECT(pb));
Regards,
Martyn
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]