Java Eclipse 内存不足且运行缓慢
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22640870/
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
Eclipse running out of memory and running slow
提问by Otto Nahmee
Although I've found similar questions, I've seem to run out of suggestions and thought of asking SO for what I've left to do.
尽管我发现了类似的问题,但我似乎已经没有建议了,并考虑向 SO 询问我剩下的工作。
I am running out of memory while using Eclipse and it starts to crawl after a couple hours to the point where I have to Force Quit. Initially it would hang and say things like "heap space out of memory." I searched on SO for things like:
我在使用 Eclipse 时内存不足,几个小时后它开始爬行到我不得不强制退出的程度。最初它会挂起并说诸如“堆空间内存不足”之类的话。我在 SO 上搜索了以下内容:
Eclipse indexer hangs with 100% cpu
Eclipse running out of memory
Eclipse java heap space out of memory
So I started to incorporate all of the suggestions, with negligible improvement. Here are all of my current changes.
所以我开始整合所有的建议,但几乎没有改进。这是我当前的所有更改。
I've been running eclipse with eclipse -debug .optionsso I can check memory usage
我一直在使用eclipse -debug .options运行 eclipse以便我可以检查内存使用情况
where the .options file has:
其中 .options 文件具有:
org.eclipse.cdt.core/debug/pdomtimings=true
org.eclipse.cdt.core/debug/indexer=true
org.eclipse.cdt.core/debug/parser=true
org.eclipse.cdt.core/debug/deltaprocessor=true
org.eclipse.cdt.core/debug/scanner=true
org.eclipse.cdt.core/debug/model=true
I've updated my /etc/eclipse.inifile to say (was before -Xmx384m so max size is much larger now)
我已经更新了我的/etc/eclipse.ini文件(在 -Xmx384m 之前,所以现在最大尺寸要大得多)
openFile
-vmargs
-XX:MaxPermSize=256m
-Xms40m
-Xmx2048m
I've also updated the indexer options (Window -> Preferences -> C/C++ -> Indexer)
我还更新了索引器选项(窗口 -> 首选项 -> C/C++ -> 索引器)
Cache limit relative to heap size: 25%
Absolute limit: 256 MB
Header file cache: 256 MB
I also unchecked Project -> Build Automatically because on any change it would momentarily hang and build the workspace
我还取消选中 Project -> Build Automatically 因为在任何更改时它都会暂时挂起并构建工作区
I've also updated the history options (Window -> Preferences -> General -> Workspace -> Local History)
我还更新了历史选项(窗口 -> 首选项 -> 常规 -> 工作区 -> 本地历史)
Days to Keep files: 1
Maximum entries per file: 50
Maximum file size (MB): 1
Lastly, in the resource filter (Project -> Properties -> Resource -> Resource Filters) I told it to ignore indexing files and folders that match *dox
最后,在资源过滤器(项目 -> 属性 -> 资源 -> 资源过滤器)中,我告诉它忽略与 *dox 匹配的索引文件和文件夹
Exclude all: Name matches *dox (file and folders)
When it starts to get super slow I'll hit ctrl + \ where I ran eclipse and I'll see that its using 100% of the heap space. Trying to increase the maximum size (-Xmx) beyond 2048 MB results in it complaining that it can't start the VM, but I'm wondering if this isn't exactly a case of how much space I give it.
当它开始变得超级慢时,我会在运行 eclipse 的地方按 ctrl + \ ,我会看到它使用了 100% 的堆空间。尝试将最大大小 (-Xmx) 增加到 2048 MB 以上会导致它抱怨它无法启动 VM,但我想知道这是否不完全是我给它多少空间的情况。
I keep the progress window open so I can see what it's trying to do, and usually it seems to get slower while indexing, but when it's crawling, it'll be so bad that merely scrolling seems to make it hang. I usually have no choice but to close Eclipse and reopen (after about 2 hours).
我保持进度窗口打开,以便我可以看到它正在尝试做什么,通常在索引时它似乎变慢了,但是当它爬行时,它会很糟糕,仅仅滚动似乎使它挂起。我通常别无选择,只能关闭 Eclipse 并重新打开(大约 2 小时后)。
What else is there left to try? Is this solely a memory issue? What else can lead me to discovering why it starts to crawl?
还有什么可以尝试的?这仅仅是内存问题吗?还有什么可以让我发现它为什么开始爬行?
This is on Ubuntu 12.04 and Eclipse 3.7.2 and Java OpenJDK 1.6.0_30-b30
这是在 Ubuntu 12.04 和 Eclipse 3.7.2 和 Java OpenJDK 1.6.0_30-b30 上
回答by Scott Shipp
It's probably a certain add-on. You should remove them all and try adding them back one-by-one. I've experienced this same kind of behavior with a certain code coverage plug-in, can't remember which one right now. Anyway, give that a try and see if you can pinpoint which one it is. Then you'll just have to find some alternative add-on for that one, that you can use instead.
这可能是某个附加组件。您应该将它们全部删除并尝试将它们一个一个地添加回来。我在某个代码覆盖率插件上遇到过同样的行为,现在不记得是哪一个了。不管怎样,试一试,看看你能不能确定它是哪一个。然后你只需要为那个插件找到一些替代的插件,你可以使用它。
回答by Vit
After 1 month of nice CDT-Eclipse work I suddenly faced today the same problem. I have tried to increase memory parameters, to uninstall plugins etc but fruitless. But than I found really helpful advice:
经过 1 个月的 CDT-Eclipse 工作,我今天突然遇到了同样的问题。我试图增加内存参数,卸载插件等,但没有结果。但比我发现真正有用的建议:
"Whenever you create a new workspace for a Mozilla source tree, you should be sure to turn off the following two settings in the workspace preferences (Window > Preferences, or Eclipse > Preferences) before creating a project in that workspace:
- in "General > Workspace", disable "Build automatically"
- in "C/C++ > Indexer", disable "Automatically update the index"
https://developer.mozilla.org/en-US/docs/Eclipse_CDT
“每当您为 Mozilla 源代码树创建新工作区时,在该工作区中创建项目之前,您应该确保关闭工作区首选项中的以下两个设置(窗口 > 首选项,或 Eclipse > 首选项):
- 在“常规”中> 工作区”,禁用“自动构建”
- 在“C/C++ > 索引器”中,禁用“自动更新索引”
https://developer.mozilla.org/en-US/docs/Eclipse_CDT
And my problem disappeared.
我的问题消失了。

