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: huge memory usage when loading raster images
Date Mon, 20 Oct 2003 11:31:44 GMT
Hi Gold,

Gold Martin wrote:

> hello,
> thank you for the last reply.
> Using Batik 1.5 I' m loading a transparent GIF - LZW raster image with 1.8
> MB (4429 * 4101 Pixel) to show in the SVGCanvas.
> When I do so and look to the Windows NT Task Manager the memory usage
> increases by 90 MB for each image I am loading.
> When I load the same raster image as PNG (also 1.8 MB) - the memory usage
> increases by 270 MB.
> Is that because Batik uses 4 Bytes for each Pixel (4429 * 4101 * 4 = ~ 72
> MB) ?

    Yes, Each of those 4Kx4K images takes about 72MB of memory.

> Is there another way to show raster images without increasing the memory
> usage so much ?

    There are a number of routes to go.  One to try would be to use a
tiled Tiff image instead of PNG or GIF, Batik should only access the
tiles needed for display with TIFF.  Still in order to show the overview
you will need to load the entire image (at some point) to sample it down
to display resolution.

    Another option, which is scalable and avoids the above issues is to
look at 'samples/extensions/opera/opera-subImage.svg'.  This is using
the 'multImage' element from SVG 1.2.  This allows you to reference
multiple sets of SVG content and select which should be used at each
zoom level.  This would allow you to provide a low res 'overview' image
and then several high res 'mid' and lots of 'high' res images.

> I want the user to click to an area in the Canvas and then load the adequate
> raster file (a map) of that area.
> But clicking to a few areas exceeds my memory (and slows performance). 

    You should remove 'old images' from the document when they aren't
being displayed (so they don't take up memory anymore - setting
the 'display' property to 'none' will have a similar effect with
current CVS).

    I am concerned that the PNG seems to take 270MB.  The Windows Task
Manager is a pretty bad way to track Java Memory usage.  The Squiggle
Browser includes a Java Memory Monitor, that can give a much more accurate
view of the real Java Heap, this might help to know if the 270MB is
a result of 'intermediate' images or if for some bizzare reason Batik
is really holding onto 270MB of image data.  You should bring up the
monitor run the Garbage Collector a couple of times, then load the image
and run the Garbage Collector a few more times and see what the difference is.

To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org

View raw message