0

When i execute the project in Netbeans 6.5, while viewing the reports (jasper reports) jasperviewer opens, but not fully. and in output window it throws exception like this:

Exception occurred during event dispatching:
java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.DataBufferByte.<init>(DataBufferByte.java:58)
    at java.awt.image.ComponentSampleModel.createDataBuffer(ComponentSampleModel.java:397)
    at java.awt.image.Raster.createWritableRaster(Raster.java:938)
    at javax.imageio.ImageTypeSpecifier.createBufferedImage(ImageTypeSpecifier.java:1169)
    at javax.imageio.ImageReader.getDestination(ImageReader.java:2879)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:943)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:915)
    at javax.imageio.ImageIO.read(ImageIO.java:1422)
    at javax.imageio.ImageIO.read(ImageIO.java:1326)
    at net.sf.jasperreports.engine.util.JRJdk14ImageReader.readImage(JRJdk14ImageReader.java:58)
    at net.sf.jasperreports.engine.util.JRImageLoader.loadImage(JRImageLoader.java:248)
    ....
Zac Thompson
  • 12,401
  • 45
  • 57
Mohanish Timble
  • 61
  • 1
  • 3
  • 6

4 Answers4

3

Give yourself more heap space:

java -Xmx512m ...

for 512M and so on.

Netbeans will give you somewhere an option to specify VM parameters (of which -Xmx is one that affects memory usage).

Another piece of advice: if you are using the bean shell compiler for Jasper Reports, don't. It's a huge memory hog and it's slow. Make sure you use the JDT compiler.

cletus
  • 616,129
  • 168
  • 910
  • 942
0

Try adding a JVM argument to your Project runtime settings to increase the amount of available heap space; e.g.

-mx256M

... will increase your available heap to 256 Megabytes.

Adamski
  • 54,009
  • 15
  • 113
  • 152
0

For a permanent solution, try profiling your application with a profiler. Check this link here

Community
  • 1
  • 1
Cshah
  • 5,612
  • 10
  • 33
  • 37
0

I like to use visualgc to see what is happening when I run out of memory. VisualGC will help you see which part of memory is actually the problem.

Here is a snippet from a question on how to set memory parameters in netbeans.

http://www.experts-exchange.com/Programming/Languages/Java/Q_21039388.html

It's been a while since I used netbeans but there is a file that is called ide.cfg

Here you can edit the line:
        -J-Xverify:none -J-Xms24m -J-Xmx96m

and make the -J-Xmx parameter to be 128 Mb like this:

        -J-Xverify:none -J-Xms24m -J-Xmx128m

On a more gerneral note: It's probably more efficient to look at the memory usage of your app. If it's doing this during development your are going to have fun with this app in production...
James Black
  • 41,583
  • 10
  • 86
  • 166