Hi Mochael,

"Bishop, Michael W. CTR USJFCOM JFL" <[email protected]> wrote 
on 02/02/2009 01:19:07 PM:

> I "lose" memory every time I switch pages by calling 
> setDocument(...) on the JSVGCanvas.  It appears from profiling that 
> this is mostly due to image loading.
> 
> The increasing memory seems to come from int[] created as:

   This is the image loading code.  The question is can you
tell what continues to reference the 'old' images?  Most
Memory profiling tools can give you the reference chain to a
GC root from an object.

> When I switch documents about 10 times, I get an 
> OutOfMemoryException.  While I keep the SVGDocuments in memory, I 
> don't load and keep images or JSVGCanvases.  It's one JSVGCanvas 
> used to display whatever "slide" (document) the user wants to see. 
> Are there some references I can tell the JSVGCanvas to release?

   I'm fairly certain the problem is that you keep the Document in
memory after it has been displayed in the Canvas (this shouldn't be
a problem but I'm guessing it is).  You could test if this is the
problem by cloning the Document either before you show it (so you
hold onto the original and display the clone) or when you are done
showing it (so you hold the clone and the canvas will drop the
reference when it switches to the next document).  If this solves
your problem then it indicates that we are leaving junk attached to
the SVG DOM (which we shouldn't be after the document is detached
from the canvas).

> Are there any gotchas I should look for?  I'm trying to figure out 
> if I'm doing something wrong specifically in my application or there's 
> a common pitfall that I can be pointed to so I can avoid this memory
> consumption.

   We do try hard to keep an eye on memory leaks, so I'm not 100%
certain the problem is entirely with Batik.

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 

Reply via email to