Hi all,
 
I'm trying to track down a memory leak in my application and I'm stuck on how 
to proceed.  I've used NetBeans to profile the application and although I'm new 
to the profiler, it seems to have to do with images.  I guess I should present 
my testing case.
 
I import a number of SVG documents as a "slide show."  The user can select any 
number of images and an SVGDocument is made from each.  Basically, each 
document has an image in its own <g> tag and an additional <g> tag so the user 
can draw on top of the image in a separate layer.  It's a pretty basic 
document.  The test folder I'm using has 20+ images, so that's how many 
SVGDocuments are being created.
 
I "lose" memory every time I switch pages by calling setDocument(...) on the 
JSVGCanvas.  It appears from profiling that this is mostly due to image loading.
 
The increasing memory seems to come from int[] created as:
 
org.apache.batik.ext.awt.image.codec.png.PNGRegistryEntry$1.run() ->
org.apache.batik.ext.awt.image.rendered.AbstractRed.getData() ->
org.apache.batik.ext.awt.image.rendered.AbstractRed.getData(java.awt.Rectangle) 
->
java.awt.image.Raster.createWritableRaster(java.awt.Image.SampleModel, 
java.awt.Point) ->
java.awt.image.SinglePixelPackedSampleModel.createDataBuffer() ->
java.awt.image.DataBufferInt.<init>
 
When I switch documents about 10 times, I get an OutOfMemoryException.  While I 
keep the SVGDocuments in memory, I don't load and keep images or JSVGCanvases.  
It's one JSVGCanvas used to display whatever "slide" (document) the user wants 
to see.  Are there some references I can tell the JSVGCanvas to release?  Are 
there any gotchas I should look for?  I'm trying to figure out if I'm doing 
something wrong specifically in my application or there's a common pitfall that 
I can be pointed to so I can avoid this memory consumption.
 
Thanks,
 
Michael Bishop
 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to