[gtkmm] how to free a pixbuf



Is it possible to free the data of a Gtk::Pixbuf?

I'm reading from the disk and displaying a sequence of images, one at the
time, in a pixbuf. The pixbuf is a member in some bigger class, so it is
the same for all images, and does not go out of scope upon each read. I
have to keep it around, to redraw a drawing area in an expose_event()
callback.

I noticed that every time I advance to the next image, the memory usage
increases by about the size of the image on disk, so I realized I have a
memory leak. That is to be expected, because every time the pixbuf is
created_from_file, new memory is allocated, but the old memory is not
freed.

I saw Glib::RefPtr<some_type>::clear(), so I tried

pixbuf.clear();

just before I load a new image, but the memory still goes up as I read new
images. What do I do?







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