Hi,

 

We are experiencing problems with the use of Batik to display a large SVG in an applet.

 

What happens is this :

The user connects and the application displays the page, the applet is loaded by the browser. The applet requests the SVG from a Servlet and then displays it using Batik.

Then the user clicks on a link in the application or in the rendered SVG and the browser displays another page.

Finally the user clicks on a link in the menu which redirects to the first page that loads the applet again.

After repeating the same tasks several times (from 5 to 20, it depends) the applet crashes or waits indefinitely for the SVG.

When the applet “waits” indefinitely (or a very long time : 2 minutes), it is trying to download the applet or the SVG (one of the two).

 

Here is the stack trace for the crash (HEAP) :

 

Exception in thread "Thread-61" java.lang.OutOfMemoryError: Java heap space

            at java.awt.image.DataBufferInt.<init>(Unknown Source)

            at java.awt.image.Raster.createPackedRaster(Unknown Source)

            at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)

            at java.awt.image.BufferedImage.<init>(Unknown Source)

            at sun.java2d.loops.GraphicsPrimitive.convertFrom(Unknown Source)

            at sun.java2d.loops.MaskBlit$General.MaskBlit(Unknown Source)

            at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Unknown Source)

            at sun.java2d.pipe.DrawImage.blitSurfaceData(Unknown Source)

            at sun.java2d.pipe.DrawImage.renderImageCopy(Unknown Source)

            at sun.java2d.pipe.DrawImage.copyImage(Unknown Source)

            at sun.java2d.pipe.DrawImage.copyImage(Unknown Source)

            at sun.java2d.pipe.ValidatePipe.copyImage(Unknown Source)

            at sun.java2d.SunGraphics2D.drawImage(Unknown Source)

            at sun.java2d.SunGraphics2D.drawImage(Unknown Source)

            at sun.plugin.util.AnimationPanel2.doPaint(Unknown Source)

            at sun.plugin.util.AnimationPanel2.run(Unknown Source)

            at java.lang.Thread.run(Unknown Source)

 

or this (Permgen) :

 

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

            at sun.plugin2.applet.Plugin2ClassLoader.defineClassHelper(Unknown Source)

            at sun.plugin2.applet.Plugin2ClassLoader.access$100(Unknown Source)

            at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)

            at java.security.AccessController.doPrivileged(Native Method)

            at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)

            at sun.plugin2.applet.JNLP2ClassLoader.findClass(Unknown Source)

            at java.lang.ClassLoader.loadClass(Unknown Source)

            at java.lang.ClassLoader.loadClass(Unknown Source)

            at org.apache.batik.bridge.UpdateManager.<init>(UpdateManager.java:161)

            at org.apache.batik.swing.svg.AbstractJSVGComponent.startSVGLoadEventDispatcher(AbstractJSVGComponent.java:878)

            at org.apache.batik.swing.svg.AbstractJSVGComponent$SVGListener.gvtBuildCompleted(AbstractJSVGComponent.java:1537)

            at org.apache.batik.swing.svg.GVTTreeBuilder$2.dispatch(GVTTreeBuilder.java:163)

            at org.apache.batik.util.EventDispatcher.dispatchEvent(EventDispatcher.java:103)

            at org.apache.batik.util.EventDispatcher.fireEvent(EventDispatcher.java:87)

            at org.apache.batik.util.EventDispatcher$1.run(EventDispatcher.java:46)

            at java.awt.event.InvocationEvent.dispatch(Unknown Source)

            at java.awt.EventQueue.dispatchEvent(Unknown Source)

            at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

            at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

            at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

            at java.awt.EventDispatchThread.run(Unknown Source)

Caused by: java.lang.reflect.InvocationTargetException

            at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

            at java.lang.reflect.Method.invoke(Unknown Source)

            ... 23 more

Caused by: java.lang.OutOfMemoryError: PermGen space

            at java.lang.ClassLoader.defineClass1(Native Method)

            at java.lang.ClassLoader.defineClassCond(Unknown Source)

            at java.lang.ClassLoader.defineClass(Unknown Source)

            at java.security.SecureClassLoader.defineClass(Unknown Source)

            at java.net.URLClassLoader.defineClass(Unknown Source)

            at java.net.URLClassLoader.defineClass(Unknown Source)

            ... 26 more

 

We have tried increasing the maximum Heap size (1024m) and MaxPermGen (256m) but it crashes nonetheless.

 

Technical details :

OS : Windows XP Pro SP2

Installed JREs :

            1.6.0_19 checked

1.6.0_07 checked

1.5.0_16 checked

1.5.0_14 not checked

1.4.2_16 not checked

“Checked” refers to the Java Runtime Environment Settins in the configuration panel)

(we have tried several combinations, but none solves the problem)

Browser : IE 6.0.2900

(it also crashes in Firefox)