GtkPixmap / Imlib memory leak problem
- From: Dave Swegen <dave recursive prestel co uk>
- To: gtk-list redhat com
- Subject: GtkPixmap / Imlib memory leak problem
- Date: Mon, 17 May 1999 15:09:05 +0100
I'm having a problem with a hideous memory leak. In my program I use imlib
to load an image, then convert the image data to a pixmap, which in turn is
converted to a GtkPixmap (using gtk_pixmap_new()).
This all works fine. The problem arises whenever I wish to replace the
gtkpixmap with a newly generated pixmap. It would seem that the GdkPixmap
info in the gtkpixmap struct is just cut loose every time I update, and
I've been completly unable to figure out how to free the pixmap.
The order of the program is something like this:
load_image() (using gdk_imlib)
update_and_render image()
display_pixmap()
I then have a callback function, which is run whnever the mouse is clicked.
The callback has the following sequence:
flood_fill_area()
update_and_render_image() <- Program size increases 3Mb every time called
display_pixmap()
The updating function looks like this:
void update_map(world *worldobj, gui_info * gui)
{
GdkPixmap *pm;
/* worldobj->map is a GdkImlibImage */
gdk_imlib_changed_image(worldobj->map);
gdk_imlib_render(worldobj->map,
worldobj->map->rgb_width,
worldobj->map->rgb_height);
pm = gdk_imlib_move_image(worldobj->map);
/* I suspect the old gdkpm is cut loose at the next line */
gui->map_pm = gtk_pixmap_new(pm, NULL);
worldobj->map_h = worldobj->map->rgb_height;
worldobj->map_w = worldobj->map->rgb_width;
gtk_fixed_put(GTK_FIXED(gui->fbox), gui->map_pm, 0, 0);
gtk_widget_show(gui->map_pm);
}
According to the imlib docs gdk_imlib_free_pixmap should be called on all
pixmaps created by imlib, but I have been unable to work out how to access
the gdkpixmap which is held by the GtkPixmap (gui->map_pm, which is
actually a GtkWidget).
Calling gtk_destroy_widget(gui->map_pm) either has no effect, or causes a
segfault.
Anyway, I will appreciate any clarification on the matter.
Cheers
Dave
--
Dave Swegen | Debian 2.1 on Linux i386 2.2.3
<dave@recursive.prestel.co.uk> | PGP key available on request
<dsw@debian.org> | Linux: The Choice of a GNU Generation
----------------------------------------------------------------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]