You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by David Avery <da...@frontgatetickets.com> on 2005/10/24 21:35:25 UTC
out of memory issue on reloading multiple
Hello Folks,
Im using
canvas.setURI(documentURL.toString());
to reload several svg files.
After about 8 reloads batik seems to be using a hugh amount of memory,
provoking a java.lang.OutOfMemory.
Are there any tips out there on cleaning up listeners, or freeing
objects so I could continue loading SVG files?
Anxious in Austin,
--
David Avery
david@frontgatetickets.com
Ph: 512.439.1209
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: out of memory issue on reloading multiple
Posted by Archie Cobbs <ar...@dellroad.org>.
David Avery wrote:
> Im using
> canvas.setURI(documentURL.toString());
>
> to reload several svg files.
>
> After about 8 reloads batik seems to be using a hugh amount of memory,
> provoking a java.lang.OutOfMemory.
>
> Are there any tips out there on cleaning up listeners, or freeing
> objects so I could continue loading SVG files?
For what it's worth...
I was uncertain about this same issue myself. As a result I decided
to create a new JSVGCanvas each time I loaded a new image, and then
replace the old one in the containing Swing component when it was ready.
-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
Re: out of memory issue on reloading multiple
Posted by th...@kodak.com.
Hi David,
David Avery <da...@frontgatetickets.com> wrote on 10/27/2005 01:55:20 PM:
> Unless it's flushed the cache contents seem to persist in the heap
> untill the JVM expires.
If so it's a major bug in the JVM. The URLImageCache class
uses java.lang.ref.SoftReference to reference the image data and
it has a ReferenceQueue registered to remove the key's who's data
have been GC'ed. There is some small chance that there is a
bug in this code, but it's been around a while and I've stressed
it quite a bit in the past.
It is an explicit part of the JavaDocs on SoftReferences that
all of then GC'able references must be cleared before an out of
memory exception is thrown.
As for the purpose, it's mostly to avoid reloading image data
when it is referenced multiple times by the same document.
If you can produce a stand alone test case where not
calling flush reliably causes an out of memory error,
but calling flush prevents it I would be very interested
in seeing it.
> Archie Cobbs wrote:
>
> > David Avery wrote:
> >
> >> Well I figured it out.
> >> canvas.flushImageCache();
> >>
> >>> After about 8 reloads batik seems to be using a hugh amount of
memory,
> >>> provoking a java.lang.OutOfMemory.
> >>
> >
> > Interesting... so what's the image cache and what does it do?
> >
> > -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
Re: out of memory issue on reloading multiple
Posted by David Avery <da...@frontgatetickets.com>.
Well it's part of JSVGComponent.class
/**
* Removes all images from the image cache.
*/
public void flushImageCache() {
ImageTagRegistry reg = ImageTagRegistry.getRegistry();
reg.flushCache();
}
ImageTagRegistry.class
public void flushCache() {
rawCache.flush();
imgCache.flush();
}
Unless it's flushed the cache contents seem to persist in the heap
untill the JVM expires.
Archie Cobbs wrote:
> David Avery wrote:
>
>> Well I figured it out.
>> canvas.flushImageCache();
>>
>>> After about 8 reloads batik seems to be using a hugh amount of memory,
>>> provoking a java.lang.OutOfMemory.
>>
>
> Interesting... so what's the image cache and what does it do?
>
> -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
Re: out of memory issue on reloading multiple
Posted by Archie Cobbs <ar...@dellroad.org>.
David Avery wrote:
> Well I figured it out.
> canvas.flushImageCache();
>
>> After about 8 reloads batik seems to be using a hugh amount of memory,
>> provoking a java.lang.OutOfMemory.
Interesting... so what's the image cache and what does it do?
-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
Re: out of memory issue on reloading multiple
Posted by David Avery <da...@frontgatetickets.com>.
Well I figured it out.
canvas.flushImageCache();
David Avery wrote:
>Hello Folks,
>Im using
>canvas.setURI(documentURL.toString());
>
>to reload several svg files.
>
> After about 8 reloads batik seems to be using a hugh amount of memory,
>provoking a java.lang.OutOfMemory.
>
>Are there any tips out there on cleaning up listeners, or freeing
>objects so I could continue loading SVG files?
>
>Anxious in Austin,
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org