Re: Memory leak reading SVG image

Bob Friesenhahn <[email protected]> Mon, 10 Oct 2005 21:12:47 -0500 (CDT)
Newsgroups gmane.comp.video.graphicsmagick.apis
Message-ID <[email protected]>
On Thu, 6 Oct 2005, Achim Domma wrote:

> the following sample application consumes more and more memory. Am I doing 
> something wrong or is this a memory leak in reading svg files? I tried it 
> with GM 1.1.4 and the current snapshot. The example svg file is pasted below 
> the code sample.

Thanks for the heads up.  I have just committed a fix to CVS on both 
the 1.1 branch and head which reduces valgrind complaints to the 
attached (for 1.2).  I believe that these complaints are all for 
singleton allocations.

==96522== Memcheck, a memory error detector for x86-linux.
==96522== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward.
==96522== Using valgrind-2.1.2.CVS, a program supervision framework for x86-linux.
==96522== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward.
==96522== For more details, rerun with: -v
==96522== 
==96522== 
==96522== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==96522== malloc/free: in use at exit: 426 bytes in 18 blocks.
==96522== malloc/free: 15428 allocs, 15410 frees, 7424877 bytes allocated.
==96522== For counts of detected errors, rerun with: -v
==96522== searching for pointers to 18 not-freed blocks.
==96522== checked 9038940 bytes.
==96522== 
==96522== 4 bytes in 1 blocks are still reachable in loss record 1 of 4
==96522==    at 0x3C03571F: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck.so)
==96522==    by 0x3C3997B9: xmlNewRMutex (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C3D7EDD: xmlInitializeDict (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C3D834A: xmlDictCreate (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C33727E: xmlInitParserCtxt (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C337AB7: xmlNewParserCtxt (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C3492AC: xmlCreatePushParserCtxt (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x818001C: ReadSVGImage (svg.c:2684)
==96522==    by 0x8087CC2: GmReadImage (constitute.c:5235)
==96522==    by 0x805BC65: GmConvertImageCommand (command.c:2755)
==96522==    by 0x80525DA: GmMagickCommand (command.c:7124)
==96522==    by 0x8076F7E: GMCommand (command.c:14412)
==96522== 
==96522== 
==96522== 62 bytes in 8 blocks are still reachable in loss record 2 of 4
==96522==    at 0x3C03571F: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck.so)
==96522==    by 0x3C39B622: xmlStrndup (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C39B695: xmlStrdup (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C332D74: xmlNewCharEncodingHandler (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C332EDA: xmlInitCharEncodingHandlers (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C33311C: xmlGetCharEncodingHandler (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C35923C: xmlAllocParserInputBuffer (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C349292: xmlCreatePushParserCtxt (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x818001C: ReadSVGImage (svg.c:2684)
==96522==    by 0x8087CC2: GmReadImage (constitute.c:5235)
==96522==    by 0x805BC65: GmConvertImageCommand (command.c:2755)
==96522==    by 0x80525DA: GmMagickCommand (command.c:7124)
==96522== 
==96522== 
==96522== 160 bytes in 8 blocks are still reachable in loss record 3 of 4
==96522==    at 0x3C03571F: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck.so)
==96522==    by 0x3C332DAC: xmlNewCharEncodingHandler (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C332EDA: xmlInitCharEncodingHandlers (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C33311C: xmlGetCharEncodingHandler (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C35923C: xmlAllocParserInputBuffer (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C349292: xmlCreatePushParserCtxt (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x818001C: ReadSVGImage (svg.c:2684)
==96522==    by 0x8087CC2: GmReadImage (constitute.c:5235)
==96522==    by 0x805BC65: GmConvertImageCommand (command.c:2755)
==96522==    by 0x80525DA: GmMagickCommand (command.c:7124)
==96522==    by 0x8076F7E: GMCommand (command.c:14412)
==96522==    by 0x805046E: main (gm.c:61)
==96522== 
==96522== 
==96522== 200 bytes in 1 blocks are still reachable in loss record 4 of 4
==96522==    at 0x3C03571F: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck.so)
==96522==    by 0x3C332E4B: xmlInitCharEncodingHandlers (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C33311C: xmlGetCharEncodingHandler (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C35923C: xmlAllocParserInputBuffer (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x3C349292: xmlCreatePushParserCtxt (in /usr/local/lib/libxml2.so.5)
==96522==    by 0x818001C: ReadSVGImage (svg.c:2684)
==96522==    by 0x8087CC2: GmReadImage (constitute.c:5235)
==96522==    by 0x805BC65: GmConvertImageCommand (command.c:2755)
==96522==    by 0x80525DA: GmMagickCommand (command.c:7124)
==96522==    by 0x8076F7E: GMCommand (command.c:14412)
==96522==    by 0x805046E: main (gm.c:61)
==96522== 
==96522== LEAK SUMMARY:
==96522==    definitely lost: 0 bytes in 0 blocks.
==96522==    possibly lost:   0 bytes in 0 blocks.
==96522==    still reachable: 426 bytes in 18 blocks.
==96522==         suppressed: 0 bytes in 0 blocks.


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl