xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Steele" <gste...@apt-cafm.com>
Subject RE: Memory & Dynamic Canvas
Date Tue, 09 May 2006 14:39:32 GMT
Hi Thomas,
I'm confident a static canvas doesn't need dispose() called but a dynamic
canvas does.  But it's probably good practice to always call dispose.  The
following is my simple test setup; Test 3 results in a heap overflow.  Thank
you for your help.

Here's my simple test setup:
Batik 1.6
JDK 5.0
2.5Mb SVG File
Windows XP
IDE Netbeans 5.0
Initial and Max Heap size set to 100Mb

Test 1: Static Canvas, dispose() not called on close
1. Open drawing
   a. Heap usage ramps upto ~90Mb
2. Close drawing (no dispose())
   a. Heap usage maintains ~90Mb
3. Reopen same drawing
   a. Heap usage drops to 50Mb then goes back to 90Mb

...I can continue closing and reopening the drawing without getting a heap
overflow exception

Test 2: Static Canvas, dispose() called on close
1. Open drawing
   a. Heap usage ramps upto ~90Mb
2. Close drawing (with dispose())
   a. Heap usage drops to ~65Mb
3. Reopen same drawing
   a. Heap usage drops to 50Mb then goes back to 90Mb

...no overflow issues on repeat

Test 3: Dynamic Canvas, dispose() not called
1. Open drawing
   a. Heap usage ramps upto ~90Mb
2. Close drawing (no dispose())
   a. Heap usage maintains ~90Mb
3. Reopen same drawing
   a. Heap overflows!

Test 4: Dynamic Canvas, dispose() called on close
1. Open drawing
   a. Heap usage ramps upto ~90Mb
2. Close drawing (with dispose())
   a. Heap usage maintains ~90Mb
3. Reopen same drawing
   a. No problem. Drops to 50Mb then ramps back to 90Mb

...no overflow issues on repeat



-----Original Message-----
From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
Sent: Tuesday, May 09, 2006 8:22 AM
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: RE: Memory & Dynamic Canvas


Hi Greg,

"Greg Steele" <gsteele@apt-cafm.com> wrote on 05/09/2006 09:05:34 AM:

> Thank you very much. Lesson learned. Removing a swing component from its
> parent container is not enough.  Dispose must be called too.  Sorry to
> clutter this mailing list with a Swing issue.

   I suspected that Swing might not be allowing the canvas to go to GC,
but you mentioned that marking the Canvas as STATIC fixed the problem,
which to me didn't sync with this being the problem.

  Was the STATIC/DYNAMIC thing just a red herring? Or are you fairly
confident that a static canvas doesn't need dispose called but a
dynamic canvas does?

> -----Original Message-----
> From: Archie Cobbs [mailto:archie@dellroad.org]
> Sent: Monday, May 08, 2006 9:07 PM
> To: batik-users@xmlgraphics.apache.org
> Subject: Re: Memory & Dynamic Canvas
>
>
> Greg Steele wrote:
> > I've been trying to track down a major memory leak in my app.  After
> > creating a very simple test app, I was able to determine that setting
> > canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC) was somehow causing
> > unused objects to remain on the heap after I removed the canvas from
the
> > container.  The memory leak goes away when I leave the canvas static;
I
> can
> > close and reopen the same SVG doc indefinitely.
> >
> > Perhaps, I'm not closing the canvas correctly?  Currently, I just
remove
> it
> > from its parent container.
>
> FWIW, my application uses a different JSVGCanvas for each image
> displayed and we don't see any leaking memory after loading
> several images.
>
> Are you sure that you're not retaining a reference to some object
somewhere
> that might indirectly reference the JSVGCanvas?
>
> FYI here's what we invoke when discarding a JSVGCanvas object:
>
>          canvas.stopProcessing();
>          canvas.dispose();
>
> Try adding one or both of those when you discard to see if that helps...
> just a wild guess.
>
> -Archie
>
>
__________________________________________________________________________
> Archie Cobbs      *        CTO, Awarix        * http://www.awarix.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message