JAI with -Dsun.java2d.noddraw=true

I just started my application with the VM argument -Dsun.java2d.noddraw=true and noticed that I get a RuntimeException while loading a terrain grid using the Geotools library which itself uses Java Advanced Imaging. As you can see from the StackTrace there seems to be a problem with creating a DataBuffer.

Exception in thread “AWT-EventQueue-0” java.lang.RuntimeException: Cannot construct DataBuffer.
at com.sun.media.jai.util.DataBufferUtils.constructDataBuffer(DataBufferUtils.java:140)
at com.sun.media.jai.util.DataBufferUtils.createDataBufferFloat(DataBufferUtils.java:222)
at javax.media.jai.RasterFactory.createBandedRaster(RasterFactory.java:349)
at javax.media.jai.RasterFactory.createBandedRaster(RasterFactory.java:248)
at org.geotools.gce.arcgrid.ArcGridRaster.readRaster(ArcGridRaster.java:366)

Now, the ArcGridRaster from the Geotools library creates the raster as following which leads to a creation of a DataBuffer:


WritableRaster raster = RasterFactory.createBandedRaster(java.awt.image.DataBuffer.TYPE_FLOAT, getNCols(), getNRows(), 1, null);

I just added the VM argument and without the application works fine. So there should be some relationship with using JAI.
If helpful: I’m using JOGL JSR-231 beta 04, Java Advanced Imaging API 1.1.2, Java Advanced Imaging ImageIO Tools 1.0_0 and Geotools 2.2.RC2.

Any suggestions how to solve this problem?

Have you tried increasing the maximum heap size with e.g. -Xmx128m ? I could imagine that disabling the DirectDraw rendering pipeline might cause more BufferedImages to be used internally to the Java2D implementation, increasing the heap pressure in your application.

Thanks a lot Ken!

When increasing the maximum heap size, the exception does not appear again.

Cheers,
Jens