Exception in thread “AWT-EventQueue-0” java.lang.OutOfMemoryError: Java heap space

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 22:09:00

问题


Exception in thread "AWT-EventQueue-0" 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.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)

Iam getting this error message when I load the Web start application from production. When I load the same production code from eclipse, the above error "java.lang.OutOfMemoryError: Java heap space" disappear and everything works fine. What could the reason, why it is working in eclipse and not in standalone.

-Pad


回答1:


Java's default heap size (at least last time I researched it) is 128 MB. The latest version of Eclipse (i.e. Helios) is set to run with a default heap size of 512 MB. (see the eclipse.ini file in your Eclipse base path).

Therefore, you are probably seeing this behavior because your application needs a heap size greater than 128 MB... which it doesn't get from your system JVM's defaults, but DOES get within the Eclipse JVM process.

In your Web Start ".jnlp" file, look for the first <j2se> element, and add a max-heap-size attribute like this:

<j2se version="1.3" initial-heap-size="256m" max-heap-size="512m"/>

Reference

http://download.oracle.com/javase/1.5.0/docs/guide/javaws/developersguide/syntax.html




回答2:


Your default max-heap-size setting in eclipse is probably different to what is configured as a default for your java webstart.
You can edit the jnlp descriptor to provide a max-heap-size parameter by adding the following tag:

<j2se version="1.4+" max-heap-size="512m"/>


来源:https://stackoverflow.com/questions/3841723/exception-in-thread-awt-eventqueue-0-java-lang-outofmemoryerror-java-heap-spa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!