Hi Michael,
"Bishop, Michael W. CTR USJFCOM JFL" <[email protected]> wrote
on 02/09/2009 01:05:12 PM:
> However, my heap size is still growing and ~10 page changes will
> cause an OutOfMemoryException error with the default (64M) heap
> size. The profiler doesn't show any other classes eating a lot of
> memory. int[] at 8172k is 94.5% of the total memory the profiler's
> heap dump tracks.
That doesn't compute for me. How can you run out of memory if
8MB represents ~95% of the memory in use? 8MB is just 12% of the
available heap.
> As for the stack trace for int[] allocations, it's all internal to
Batik.
I wasn't asking about the stack trace for int[] allocations.
I was asking what the Garbage collection root (GC Root) was for
the arrays. The only way an object can avoid GC is be being
referenced by a GC root or another object that is referenced by
a GC root. Examples of GC roots are any class static variables,
and variables on the stack (these are the main two).
Typically memory profilers will let you walk back along the
chain of references till you reach a root. Knowing what that
chain is, is the most useful piece of information for fixing
memory leaks like this.
> For the record, this is Batik 1.7 final with Java 1.6u11 (Windows
> XP). I'm still doing some digging and learning profiling in
> general, but I wanted to report the results of the changes you
suggested.
BTW you said the document's consisted of basically just an
'svg' and an 'image' element. Does the image element reference
an external file or is the image base64 encoded in the file itself?
> From: [email protected] [mailto:[email protected]]
> Sent: Mon 2/9/2009 6:26 AM
> To: [email protected]
> Cc: [email protected]
> Subject: Re: Memory leak switching documents?
>
>
>
> 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]
> >
>
> [attachment "winmail.dat" deleted by Thomas E. DeWeese/449433/EKC]
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]