Mem leak in ImageToBlob in GrahicsMagick
Swiss army knife of image processing
Brought to you by:
bfriesen
I am using graphicsmagick-1.3.22, and I am making use of imagetoblob api, I found that there is a huge chunk of memory which is not freed up in my code.
I am calling DestroyImageList, DestroyExceptionInfo and DestroyImageInfo at the end.
I also tried calling destroyblob, I am making use of valgrind to find the leak. could you please let me know what could be the possible solution for this issue
Please take a look at tests/rwblob.c in the GraphicsMagick source code as a working example. This is a test program which uses ImageToBlob(), and does not seem to have any leaks since it is part of the test suite. You should not be using DestroyBlob() since that has a completely different purpose.
Assuming that you have debug symbols enabled in the GraphicsMagick build and your application's own build, valgrind should indicate which function and line of code created the huge allocation.
Thanks for your input Bob, I was able to figure out the issue. the imageToBlob returns a memory buffer and I assigned its address to a pointer. After all the operation I free up the pointer using free(). Now I dont see any memory leaks in my code. You can close this ticket now.
It is good that you found the cause of the leak. The returned memory buffer is not owned by GraphicsMagick.