[gnome-love] gdk-pixbuf leaking memory? (or is it me?)



As a fairly experienced Java programmer i finally had an itch big enough
to start looking into writing gnome programs. So now I've started
writing a program to add metadata to the pictures I've taken with my
digicam.

Now I've hit a problem, which I'm sure that you people can help me with.
The program opens and scales a lot of fairly big jpeg files (about a MiB
each) and displays them to the user, but after a couple of images my
memory is eaten by memory leaks. Basically it uses
gdk_pixbuf_new_from_file() and gdk_pixbuf_scale_simple() to create a
GdkPixbuf structure to hand over to the GtkImage constructor and later
display to the user.

So, what can I do to free the memory that these functions allocate?
calling g_object_unref() on the GdkPixbuf that
gdk_pixbuf_new_from_file() returns doesn't seem to free the resources.

I've written a trivial test program to illustrate the problem I
experience (attached). Modify it to point to a jpeg image of your choice
and run it with './leak |grep Total' and try different number of
iterations and you will see that the more time the image gets read and
unref()-ed the more memory the program will occupy.

I hope anyone has time to explain to me what I do wrong :)

cheers!

Attachment: leak.c
Description: Text Data



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