Hello,

I would like to ask you about potential memory leak in Mapnik layer code. Here is the suspected place of memory leak:
mapnik_interface.c:247

if ( image.painted() ) {
unsigned char *ImageRawDataPtr = (unsigned char *) g_malloc(width * 4 * height);
        if (!ImageRawDataPtr)
                return NULL;
        memcpy(ImageRawDataPtr, image.raw_data(), width * height * 4);
pixbuf = gdk_pixbuf_new_from_data(ImageRawDataPtr, GDK_COLORSPACE_RGB, TRUE, 8, width, height, width * 4, NULL, NULL);
}

Memory is allocated by g_malloc() and passed to gdk_pixbuf_new_from_data(). Eight argument to the gdk_pixbuf_new_from_data() function is a "Function used to free the data when the pixbuf's reference count drops to zero, or NULL if the data should not be freed." Since in the code the argument is NULL, I suspect that the ImageRawDataPtr buffer will never be freed after pixbuf becomes unused/not referenced anymore.

Am I understanding the gdk_pixbuf_new_from_data() function and its 'destroy_fn' argument correctly?

https://developer.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-data



Best regards,

Kamil


_______________________________________________
Viking-devel mailing list
Viking-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viking-devel
Viking home page: http://viking.sf.net/

Reply via email to