线程“AWT-EventQueue-0”中的异常 java.lang.OutOfMemoryError: Java heap space

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3841723/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 03:37:21  来源:igfitidea点击:

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

javajava-web-startout-of-memory

提问by SPD

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.

当我从生产中加载 Web 启动应用程序时,我收到此错误消息。当我从 Eclipse 加载相同的生产代码时,上述错误“java.lang.OutOfMemoryError:Java 堆空间”消失,一切正常。可能是什么原因,为什么它在 eclipse 中工作而不是在独立工作。

-Pad

-软垫

采纳答案by Steve Perkins

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.inifile in your Eclipse base path).

Java 的默认堆大小(至少我上次研究它时)是 128 MB。最新版本的 Eclipse(即 Helios)设置为以 512 MB 的默认堆大小运行。(请参阅eclipse.iniEclipse 基本路径中的文件)。

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.

因此,您可能会看到这种行为,因为您的应用程序需要大于 128 MB 的堆大小……它不是从系统 JVM 的默认设置中获得的,而是在 Eclipse JVM 进程中获得的。

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

在您的 Web Start“.jnlp”文件中,查找第一个<j2se>元素,并添加如下max-heap-size属性:

<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

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

回答by crowne

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:

您在 eclipse 中的默认 max-heap-size 设置可能与您的 java webstart 的默认设置不同。
您可以通过添加以下标记来编辑 jnlp 描述符以提供 max-heap-size 参数:

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