简体   繁体   English

在eclipse中无法解决“Java堆空间”错误

[英]Can't solve “Java heap space” error in eclipse

While running my Java code in Eclipse IDE, I got the error: 在Eclipse IDE中运行我的Java代码时,出现了错误:

Exception in thread "D3D Screen Updater" Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space 线程“D3D Screen Updater”中的异常线程 “AWT-EventQueue-0”中的 异常 java.lang.OutOfMemoryError:Java堆空间

I searched for this error and tried solutions described here and here , but they did not work. 我搜索了这个错误并尝试了这里这里描述的解决方案,但它们没有用。

I changed these parameters in eclipse.ini : 我在eclipse.ini中更改了这些参数:

--launcher.XXMaxPermSize --launcher.XXMaxPermSize

512M 512M

-Xms40m -Xms40m

-Xmx512m -Xmx512m

to: 至:

--launcher.XXMaxPermSize --launcher.XXMaxPermSize

1024M 1024M

-Xms512m -Xms512m

-Xmx2048m -Xmx2048m

EDIT: 编辑:

I changed this parameters at Run Configurations: 我在运行配置中更改了此参数:

在此输入图像描述

But I still get the same error. 但我仍然得到同样的错误。 Am I missing something? 我错过了什么吗?

The memory settings in eclipse.ini is allocated to Eclipse IDE only, not the program you want to run. eclipse.ini中的内存设置仅分配给Eclipse IDE,而不是您要运行的程序。 A very common mistake is updated the heap size in eclipse.ini, and expects it to solve above out of memory problem. 一个非常常见的错误是在eclipse.ini中更新堆大小,并期望它解决上面的内存不足问题。

http://www.mkyong.com/eclipse/eclipse-java-lang-outofmemoryerror-java-heap-space/ http://www.mkyong.com/eclipse/eclipse-java-lang-outofmemoryerror-java-heap-space/

Where is the "vmargs" option? “vmargs”选项在哪里? If you set the min/max heap, you probably need to do it on the main process, not the launcher. 如果设置最小/最大堆,则可能需要在主进程而不是启动程序上执行此操作。

See the Eclipse FAQ item on setting VM options. 请参阅有关设置VM选项的Eclipse FAQ项

That launcher PermSize opt is a bit ridiculous. 那个发射器PermSize opt有点荒谬。 Unless you know it is launcher PermSize causing the OOM, keep it at the default of 256m. 除非您知道它是启动Om的启动程序PermSize,否则保持默认值为256m。

[EDIT] [编辑]

As pointed out else-thread, if this is happening when you run your Java program from Eclipse, you tweak those settings within the "Run Configuration" for that program, not Eclipse.ini. 正如指出的那样,如果在 Eclipse运行Java程序时发生这种情况,则在该程序的“运行配置”中调整这些设置,而不是Eclipse.ini。

Also, remember that you can tweak the VM options all you want, but if the program wants to eat all the resources on the box before it OOMs, no amount of tweaking can mitigate this. 此外,请记住,您可以随心所欲地调整VM选项,但如果程序想要在OOM之前吃掉盒子上的所有资源,那么任何调整都不能减轻这种影响。

Assuming you have 4gb or more RAM, try something like this in eclipse.ini (notice the capital/small letter "m"): 假设你有4GB或更多RAM,请在eclipse.ini中尝试这样的事情(注意大写/小写字母“m”):

--launcher.XXMaxPermSize
1024M
--launcher.XXMaxPermSize
1024m
-vmargs
-Xms512m
-Xmx2048m

If we are using windows try this: 如果我们使用Windows试试这个:

Try setting a Windows System Environment variable called _JAVA_OPTIONS with the heap size you want. 尝试使用所需的堆大小设置名为_JAVA_OPTIONS的Windows系统环境变量。 Java should be able to find it and act accordingly Java应该能够找到它并采取相应的行动

Below settings workes for me : -Xms512m -Xmx1024m -XX:MaxPermSize=512m 以下设置适用于我:-Xms512m -Xmx1024m -XX:MaxPermSize = 512m

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

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