xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Archie Cobbs <arc...@dellroad.org>
Subject Batik memory leak
Date Mon, 13 Dec 2004 20:03:10 GMT
There was a post recently about long running Batik applications
running out of memory. I've experienced this problem too. Here is
my current theory about what's going on, at least in my case..

Our application animates an SVG document by adding and removing
nodes, and also by modifying node attributes. A mouse listener
is alwyas added to newly added nodes - and the same listener object
is added every time.

I've checked that we are removing the nodes that we add, so that
we're not just growing the document itself.

The objects that accumulate in my heap are never-freed are instances
of BridgeContext$EventListenerMemento. These instances remain in the
BridgeContext instance field "eventListenerSet", causing this set to
grow in size until memory is exhausted. In our application, this takes
a couple of days to occur.

The EventListenerMemento objects contain two SoftReference. When either
reference is cleared, the EventListenerMemento is removed from
"eventListenerSet". Of course this can only happen when there are no
strong references to the soft-referenced object.

One SoftReference points into the DOM and the other points to the Listener.
Clearly, live DOM objects are always going to be referenced.

As for the Listener, suppose the application uses the same Listener
object over and over again. Then any EventListenerMemento objects that
reference that Listener will never be cleared either.

The result is that the EventListenerMemento object accumulate
without bound.

When I load a completely new document, the EventListenerMemento objects
are all freed as expected because the old DOM is no longer referenced.

As a workaround I tried to instantiating a new Listener object for
each registration instead of re-using the same one. This helped
(I think?) however, there is still a major memory leak of the
EventListenerMemento objects.

I'm not sure what the right way to fix this would be. In any case it
seems like the Memento class has a design flaw. But also I don't understand
why my workaround didn't fix the problem... i.e., perhaps there is some
code that is calling BridgeContext.storeEventListener() that shouldn't be.

There are only 24 instances in Batik where BridgeContext.storeEventListener()
is invoked.. perhaps one or more of these is inappropriate?

Any help or insights greatly appreciated.

Thanks,
-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com


*
Confidentiality Notice: This e-mail message, including any attachments, is for the sole use
of the intended recipient(s) and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply e-mail and destroy all copies of the original
message.
*


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


Mime
View raw message