How to deal with a possible Memory Leak when using GdkPixMap


I have written a program pretty much by re-adjusting the scribble
example from the GTK Tutorial, instead of creating my own PixMap in
the configure_event I called the following function which creates a
pixmap from file:

GdkPixmap* gdk_pixmap_new_from_file( const char *filename )
        GdkPixbuf *pixbuf;
        GdkPixmap *pixmap;

        pixbuf = gdk_pixbuf_new_from_file( filename,NULL);
        if (!pixbuf)
                g_print( "Could not load `%s'!\n", filename );
                return NULL;

        gdk_pixbuf_render_pixmap_and_mask( pixbuf, &pixmap, NULL, 1 );

        gdk_pixbuf_unref( pixbuf );

        return pixmap;

I have this function called everytime expose_event is called because
the file that will get displayed in the drawing area keeps getting
updated by another program.

As the program runs and I move the mouse around the screen making
marks my CPU activity jumps dramatically and the virtual memory
occupied by the X-Window seems to be increasing on like an exponential

I am wondering if maybe there is a call that can free up some of the
space as I recall the gdk_pixmap_new_from_file in the expose_event
callback. Or some other solution to mitigate this problem

thanks a lot,


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