无法解决eclipse中的“Java heap space”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27132169/
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
Can't solve "Java heap space" error in eclipse
提问by Rikkin
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 屏幕更新程序”中的异常线程“AWT-EventQueue-0”中的异常java.lang.OutOfMemoryError:Java 堆空间
I searched for this error and tried solutions described hereand here, but they did not work.
我搜索了此错误并尝试了此处和此处描述的解决方案,但它们不起作用。
I changed these parameters in eclipse.ini:
我在eclipse.ini 中更改了这些参数:
--launcher.XXMaxPermSize
512M
-Xms40m
-Xmx512m
--launcher.XXMaxPermSize
512M
-Xms40m
-Xmx512m
to:
到:
--launcher.XXMaxPermSize
1024M
-Xms512m
-Xmx2048m
--launcher.XXMaxPermSize
1024M
-Xms512m
-Xmx2048m
EDIT:
编辑:
I changed this parameters at Run Configurations:
我在运行配置中更改了此参数:
But I still get the same error. Am I missing something?
但我仍然得到同样的错误。我错过了什么吗?
采纳答案by Rikkin
Where is the "vmargs" option? If you set the min/max heap, you probably need to do it on the main process, not the launcher.
“vmargs”选项在哪里?如果你设置了最小/最大堆,你可能需要在主进程上做,而不是在启动器上。
See the Eclipse FAQ itemon setting VM options.
请参阅有关设置 VM 选项的Eclipse FAQ 项目。
That launcher PermSize opt is a bit ridiculous. Unless you know it is launcher PermSize causing the OOM, keep it at the default of 256m.
那个启动器 PermSize opt 有点荒谬。除非您知道是启动器 PermSize 导致 OOM,否则将其保持为默认值 256m。
[EDIT]
[编辑]
As pointed out else-thread, if this is happening when you run your Java program fromEclipse, you tweak those settings within the "Run Configuration" for that program, not Eclipse.ini.
正如 else-thread 所指出的,如果在您从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 之前吃掉机器上的所有资源,则再多的调整也无法缓解这种情况。
回答by elsadek
The memory settings in eclipse.ini is allocated to Eclipse IDE only, not the program you want to run. A very common mistake is updated the heap size in eclipse.ini, and expects it to solve above out of memory problem.
eclipse.ini 中的内存设置仅分配给 Eclipse IDE,而不是您要运行的程序。一个很常见的错误是在 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/
回答by gromm
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
回答by Sharif
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 should be able to find it and act accordingly
尝试使用所需的堆大小设置名为 _JAVA_OPTIONS 的 Windows 系统环境变量。Java 应该能够找到它并采取相应的行动
Below settings workes for me : -Xms512m -Xmx1024m -XX:MaxPermSize=512m
以下设置对我有用:-Xms512m -Xmx1024m -XX:MaxPermSize=512m