xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Plotkin <erkyr...@eblong.com>
Subject Memory leaking from MultipleGradientPaintContext
Date Wed, 07 Dec 2005 21:49:50 GMT
Consider the document <http://www.eblong.com/zarf/tmp/splat.svg>. It's a 
small interactive thing: click and drag the mouse, and the green 
transparent bar follows you. Also, pretty gradient background.

This works on my friend's Mac (OSX 10.3.9). On my Mac (OSX 10.4.2), Java's 
heap fills up. The more I move the mouse, the more memory gets used. (But 
only if I'm dragging the green bar across the four green shapes!) I hit 
java.lang.OutOfMemoryError very quickly -- about fifty mouse-move events.

I'm using a snapshot of the SVN repository from 2005-Nov-13. I fetched it 
with "svn checkout -r 333250 
http://svn.apache.org/repos/asf/xmlgraphics/batik/trunk". (I grabbed this 
in order to pick up the "slow rendering on OSX 10.4" fix that circulated a 
couple of months ago.)

I have mostly done this testing in my own app, but it happens in Squiggle 
also -- the Squiggle at SVN 333250, that is. It does *not* happen with the 
Squiggle from your last public release.

I did some excavation with java's profiling option (-Xrunhprof). Turns out 
that what's clogging memory is gigantic int arrays, coming from inside 
MultipleGradientPaintContext. The top of the call stack in question:

java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
java.awt.image.Raster.createPackedRaster(Raster.java:452)
java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
org.apache.batik.ext.awt.MultipleGradientPaintContext.getCachedRaster(<Unknown>:Unknown
line)
org.apache.batik.ext.awt.MultipleGradientPaintContext.getRaster(<Unknown>:Unknown line)
apple.awt.OSXSurfaceData.setupPaint(OSXSurfaceData.java:709)
apple.awt.OSXSurfaceData.setupGraphicsState(OSXSurfaceData.java:1013)
apple.awt.OSXSurfaceData.setupGraphicsState(OSXSurfaceData.java:978)
...etc

So it's creating a big raster (the size of the window) for my 
SpaceGradient gradient object; and the raster never gets freed. Repeat 
fifty times, and Java falls over.

(I see that MultipleGradientPaintContext has a weak-reference caching 
mechanism. I don't quite grok how it works, but it obviously isn't working 
for me. (Perhaps the cache is failing to handle the alternation of 
requests at different sizes?) But even without the caching, it's a bug 
that these rasters are being retained.)

--Z

"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
*
I'm still thinking about what to put in this space.

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