xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas DeWeese <Thomas.DeWe...@Kodak.com>
Subject Re: Object retention when using removeChild
Date Mon, 16 Jun 2003 11:51:23 GMT
Hi Daniel.

Spasojevic, Daniel wrote:

>Firstly, I think that the Batik SVG toolkit is very good, and I have been very impressed
with the overall quality and number of features implemented.
>
    Thanks.

>
>I am having trouble removing nodes from a SVG document that has been
>associated with a JSVGCanvas object. The problem is that although calling removeChild()
stops the nodes from being displayed, it seems that the objects associated with that node
are retained - preventing the removed nodes from being garbage collected. I am using Batik
1.5, the problem appears when using 1.4.1_02 and 1.4.1_03 of Java, and under Windows 2000
and KDE on linux.
>
    Which Batik 1.5? Beta 5?

>Hopefully this is due to a coding error on my part.
>  
>
    One can always hope :)  However I think/know there is a memory leak 
here, I have found
and fixed at least one based on your information already.

>I wrote a simple test program that built a SVG document that included a text element,
associated it with a JSVGCanvas, then removed all child nodes of the document root. Using
JProfiler, I found the following references to associated SVGOMTextElement (the format of
this output is: name of the referant, number of references, total size of references):
>  
>
    Thanks for taking the time to do this.  Good tests help a _lot_ I 
unfortuantely do not
have access to JProfiler.  Are you up for working through this with 
diffs etc?

>--- Incoming references after removeChild()
>  
>
I have categorized these:

Known (or strongly suspected) safe:

>field e of org.apache.batik.bridge.SVGTextElementBridge	1	40 
>field ownerElement of org.apache.batik.dom.GenericAttr	2	80
>field parentNode of org.apache.batik.dom.GenericText	1	40
>field target of field this$0 of org.apache.batik.dom.AbstractParentNode$ChildNodes
>1	24
>field this$0 of
>org.apache.batik.dom.AbstractParentNode$ExtendedNamedNodeHashMap	1 24
>field this$0 of
>org.apache.batik.dom.AbstractParentNode$ExtendedNamedNodeHashMap	1 24
>  
>
Now a known problem:

>org.apache.batik.bridge.BridgeContext$EventListenerMememto
>2	48
>  
>
    This class is now using SoftReferences in my local copy so it will 
not keep the
object in memory.  This change did not effect proper function, I still 
need to add a
ReferenceQueue so we don't accumulate Mememto's.  This will probably be
committed to CVS tonight.

Unknown source:

>class array content	6	784
>field value of java.util.HashTable$Entry
>1	24
>  
>
    I am especially baffled by the array references.  The HashTable may 
(or may
or may not be) harmless.

>These references are preventing the object from being garbage collected.
>After many additions and removals during the execution of my application,
>this causes a significant increase in the memory used.
>  
>




---------------------------------------------------------------------
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