xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Helder Magalhães <helder.magalh...@gmail.com>
Subject Re: Memory leak in tooltips ?
Date Mon, 20 Apr 2009 13:23:11 GMT
Hi Ulric,


> I'm trying to avoid a memory leak in my application, and after tracking
> all possibilities in my code, I wonder if the problem is not in batik's
> tooltips.

Humm... This would be pretty weird, in my opinion...


> The problem appears in a dialog with a Jtree and a jsvgCanvas.
> Jtree is used to select the svgDocument.
>
> Selecting a node in jtree starts a new document creation each time.

This may be a source of slowness and extra memory consumption. Do you
really start a new environment every time or are you using
"setDocument" in order to avoid some of the overhead?


> The problem appears on the big document when mouse is just over an object which
> have a <desc> or <title> item. This shows a tooltip (and I suppose batik
> keep a reference on last tooltip shown). I have no listener for
> mouseover in my program and so no reference to ti.
>
> I can go back to the small document, but coming back again to the big
> document is impossible. gc cannot free memory (stays around 350Mo)
>
> In the same run, and before gc is completely stucked, I select small
> document again, which is rendered correctly. I put the mouse over an
> object with a tooltip (so I think the last tooltip shown is replaced
> with a reference to an object of the small document)
>
> Then selecting again the big document causes a correct rendering, gc
> frees memory correctly.

I'm guessing that the tooltip may simply be delaying the garbage
collection a bit, something which can (hypothetically) cause this
behavior as you are a bit close to the edge (memory provided to the
JVM versus memory used).

As you didn't provide much information, here goes:
 * How are you switching the documents? (Though setDocument?
Destroying the current one and creating a new one?)
 * Have you tried explicitly invoking the GC (System.gc(), keep in
mind that this can become a bottleneck [1]) after destroying a
document and prior to creating a new one?


> Batik is in version 1.7

And a few more:
 * Can you confirm the same behavior with the trunk version [2] (or a
nightly build [3])?
 * Please provide relevant information such as Java and operating
system versions, possibly a code snippet, etc.


Hope this helps,
 Helder


[1] http://www.petefreitag.com/articles/gctuning/
[2] http://xmlgraphics.apache.org/batik/download.cgi#Subversion+repository
[3] http://arc.mcc.id.au/batik-nightly/

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