Re: Memory leak reading SVG image

Bob Friesenhahn <[email protected]> Sat, 8 Oct 2005 18:45:19 -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.

While I have not investigated the leak in any detail, it is useful to 
know that SVG rendering is based on MVG drawing commands and there is 
an unusual design in that the Image accumulates every MVG drawing 
command since the dawn of (its) time in a huge attribute string with 
the key "[MVG]".  Besides consuming ever more memory, you should 
notice that execution gets slower.

It is likely that adding the line

   image.attribute("[MVG]","");

to the loop will eliminate most of the leak by resetting the attribute 
to an empty string.

Bob
======================================
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/


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