Valgrind reports a memory leak when I run this simple test program:
#include <gdk-pixbuf/gdk-pixbuf.h>
int main() {
GdkPixbuf* buf;
GError* err = NULL;
buf = gdk_pixbuf_new_from_file("test.jpg", &err);
g_assert_no_error(err);
g_object_unref(buf);
return 0;
}
I'm aware of the issues regarding Valgrind and GLib/GDK/GTK, and of the several StackOverflow answers (such as this one, this other one, and others) regarding this issue.
For GLib it's enough to prefix the valgrind
command with G_DEBUG=gc-friendly G_SLICE=always-malloc
(though I still have some "still reacheable" leaks, which I ignore if they come from GLib).
However, with this small program I get a lot of "possibly lost" leaks. I have also tried other prefixes, such as G_DEBUG=resident-modules
(suggested here) and G_SLICE=debug-blocks
(suggested here), but the "possibly lost" leaks remain. I also tried several of the GNOME suppressions, namely the GDK one, but to no avail.
My question is: is my only alternative to create a suppression file for this case or is something wrong with the code?
The program was compiled with:
gcc -Wall -std=c99 -g -pedantic `pkg-config --cflags glib-2.0 gdk-pixbuf-2.0` pixbuf.c -o pixbuf `pkg-config --libs glib-2.0 gdk-pixbuf-2.0`
I'm using GDK-Pixbuf 2.30.7 (Ubuntu 14.04).
Thanks in advance.