简体   繁体   English

Netbeans中的Jasperviewer:java.lang.OutOfMemoryError:Java堆空间

[英]Jasperviewer in Netbeans: java.lang.OutOfMemoryError: Java heap space

When i execute the project in Netbeans 6.5, while viewing the reports (jasper reports) jasperviewer opens, but not fully. 当我在Netbeans 6.5中执行项目时,在查看报告(碧玉报告)时,jasperviewer会打开,但不能完全打开。 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)
    ....

Give yourself more heap space: 给自己更多的堆空间:

java -Xmx512m ...

for 512M and so on. 512M等。

Netbeans will give you somewhere an option to specify VM parameters (of which -Xmx is one that affects memory usage). Netbeans将为您提供指定VM参数的选项(其中-Xmx是影响内存使用的参数)。

Another piece of advice: if you are using the bean shell compiler for Jasper Reports, don't. 另一条建议:如果您正在使用Jasper Reports的bean shell编译器,请不要使用。 It's a huge memory hog and it's slow. 这是一个巨大的内存消耗,而且速度很慢。 Make sure you use the JDT compiler. 确保使用JDT编译器。

Try adding a JVM argument to your Project runtime settings to increase the amount of available heap space; 尝试在项目运行时设置中添加JVM参数,以增加可用堆空间; eg 例如

-mx256M

... will increase your available heap to 256 Megabytes. ...将使可用堆增加到256 MB。

For a permanent solution, try profiling your application with a profiler. 对于永久解决方案,请尝试使用探查器对应用程序进行性能分析。 Check this link here 在这里检查此链接

I like to use visualgc to see what is happening when I run out of memory. 我喜欢使用visualgc查看内存不足时发生的情况。 VisualGC will help you see which part of memory is actually the problem. VisualGC将帮助您查看实际上是内存的哪一部分。

Here is a snippet from a question on how to set memory parameters in netbeans. 这是一个有关如何在netbeans中设置内存参数的问题的摘录。

http://www.experts-exchange.com/Programming/Languages/Java/Q_21039388.html 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...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM