如何减少 Eclipse 的内存使用量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1490803/
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-09-10 18:57:46  来源:igfitidea点击:

How to reduce Eclipse's memory usage?

eclipse

提问by AngryHacker

The memory usage of Eclipse 3.4 is through the roof to the point where it's becoming an issue.

Eclipse 3.4 的内存使用量已经到了成为问题的地步。

I have a simple BlackBerry project loaded and the usage skyrockets to nearly 400 MB, sometimes higher. Is there something that can be done to bring it down?

我加载了一个简单的 BlackBerry 项目,使用量猛增至近 400 MB,有时甚至更高。有什么办法可以将其降低吗?

回答by Vineet Reynolds

Eclipse 3.4 can consume a lot more memory than the previous versions, courtesy the spellchecker plug-in.

Eclipse 3.4 可以比以前的版本消耗更多的内存,这是由拼写检查插件提供的

You can switch off the plug-in by going to Window -> Preferences -> General -> Editors -> Text Editors -> Spelling, and unchecking the box title 'Enable spell checking'.

您可以通过转到窗口 -> 首选项 -> 常规 -> 编辑器 -> 文本编辑器 -> 拼写并取消选中框标题“启用拼写检查”来关闭插件。

Of course, the tips offered to use larger heap sizes and better garbage collectors would do you good as well.

当然,提供的使用更大的堆大小和更好的垃圾收集器的技巧对您也有好处。

回答by maaw

Checking General -> Show heap statuswill enable this

检查General -> Show heap status将启用此

Eclipse heap status bar

Eclipse 堆状态栏

in the bottom bar. This way you can manually run the garbage collector whenever you want by clicking on the trash can. It's not a fix, more like a workaround, but it helped reduce massively my RAM / CPU usage.

在底部栏中。通过这种方式,您可以随时通过单击垃圾桶手动运行垃圾收集器。这不是修复,更像是一种变通方法,但它有助于大量减少我的 RAM/CPU 使用率。

回答by Jon Skeet

While you probably couldtinker with the configuration, removing various plugins etc, it's likely to be more cost effective to buy more memory. How much do you currently have? I would consider a developer machine with less than 2GB of memory to be under spec, and I suspect many people would double that...

虽然您可能可以修改配置、删除各种插件等,但购买更多内存可能更具成本效益。你目前有多少?我会认为内存小于 2GB 的开发人员机器符合规范,我怀疑很多人会将其翻倍......

回答by Mark

In Eclipse Luna 4.4.1Was trying to cut my memory usage in Eclipse. I managed to shave mine from 600mb to 300mb. I did the following:

在 Eclipse Luna 4.4.1 中试图减少我在 Eclipse 中的内存使用量。我设法将我的大小从 600mb 减少到 300mb。我做了以下事情:

  • Turned off the plugins activated on startup that I wasn't using. Windows > Preferences > General > Startup and Shutdown

  • Closed projects I wasn't working on at the time.

  • 关闭我没有使用的启动时激活的插件。 Windows > 首选项 > 常规 > 启动和关机

  • 关闭了我当时没有工作的项目。

Found the hints/tips here : http://blog.elijaa.org/2010/09/20/tricks-to-speed-up-eclipse-php-helios-pdt-2-2/

在这里找到提示/技巧:http: //blog.elijaa.org/2010/09/20/tricks-to-speed-up-eclipse-php-helios-pdt-2-2/

回答by Rich Seller

Modern versions of Eclipse do need quite a bit of RAM to do their thing. But should still run pretty fast on any modern machine.

Eclipse 的现代版本确实需要相当多的 RAM 来完成它们的工作。但在任何现代机器上仍应运行得相当快。

Assuming you have enough physical memory (2GB is fine unless you have lots of other processes running, or you're using RAD), see this article on Eclipse's memory usagefor some tips on tweaking the settings. The two most common culprits are Xmx and/or MaxPermSize being set too low (Xmx defaults to 256M and MaxPermSize defaults to 64M).

假设您有足够的物理内存(2GB 就可以了,除非您有很多其他进程正在运行,或者您正在使用 RAD),请参阅这篇关于Eclipse 内存使用的文章,了解有关调整设置的一些技巧。两个最常见的罪魁祸首是 Xmx 和/或 MaxPermSize 设置得太低(Xmx 默认为 256M,MaxPermSize 默认为 64M)。

You modify the values by passing command line arguments or tweaking the eclipse.ini in the Eclipse install location.

您可以通过传递命令行参数或调整 Eclipse 安装位置中的 eclipse.ini 来修改这些值。

You should end up with something like this:

你应该得到这样的结果:

...
-vmargs
-Xms128m
-Xmx1024m 
-XX:MaxPermSize=128m

回答by Mike

My Eclipse is taking over 800MB resident, and 2GB virtual (part of it swapped out perhaps). Java canbe a hog, it's giving Java bad press all the time.

我的 Eclipse 占用了超过 800MB 的常驻内存和 2GB 的虚拟内存(其中一部分可能被换掉了)。Java可能是个猪,它一直给 Java 带来负面影响。

However, there is a little something that many people don't know: the incremental garbage collector. -XincgcThe side effect is that it hands memory back to the system from time to time. By default Java just takes and takes, and when it doesn't need memory anymore, it keeps it for itself. The incgc is a different strategy where it becomes more reasonable to assume that memory can be handed back the system without running into trouble. This can however affect performance.

然而,有一点很多人不知道:增量垃圾收集器。-Xincgc副作用是它不时将内存交还给系统。默认情况下,Java 只是获取和获取,当它不再需要内存时,它会为自己保留它。incgc 是一种不同的策略,它更合理地假设可以将内存交还给系统而不会遇到麻烦。但是,这会影响性能。

There are many garbage collection settings. You can also have multiple threads handle GC. The parallel GC does that. Not sure if that one hands memory back, don't think so.

有许多垃圾收集设置。您还可以让多个线程处理 GC。并行 GC 就是这样做的。不确定那个人是否恢复了记忆,不要这么认为。

回答by Ebru Yener

Remove +UseG1GCoption from eclipse.ini. I've read from herethat It is only used for araound 6GB heap memory.

+UseG1GC从 eclipse.ini 中删除选项。我从这里读到它仅用于大约 6GB 堆内存。

回答by Gy?rgy Andrasek

If 400 Mb of RAM is a big issue for you, you might want to try another IDE. Eclipse stores a lotof state information, some or most of which you don't actually need. That's a design choice.

如果 400 Mb 的 RAM 对您来说是一个大问题,您可能想尝试另一个 IDE。Eclipse 存储了许多状态信息,其中一些或大部分您实际上并不需要。这是一个设计选择。

Right now, I have the same project open in both Eclipse and QtCreator: after a clean rebuild, Eclipse uses 156 Mb RAM, Qt Creator is happy with 66 Mb.

现在,我在 Eclipse 和 QtCreator 中打开了相同的项目:干净重建后,Eclipse 使用 156 Mb RAM,Qt Creator 对 66 Mb 感到满意。

回答by Tim Spann

You can try the 64bit version of Eclipse with the 64bit version of JDK on Windows 7. Those both caused some odd issues with the 3rd party Framework I have to work with. The 32-bit of JRockit (free now) from Oracle seems to be faster and be a little better on memory. This is my Eclipse.ini settings:

您可以在 Windows 7 上尝试 64 位版本的 Eclipse 和 64 位版本的 JDK。这些都导致了我必须使用的第 3 方框架的一些奇怪问题。来自 Oracle 的 32 位 JRockit(现在免费)似乎更快,并且在内存上也更好一些。这是我的 Eclipse.ini 设置:

This is my eclipse inn

这是我的日食旅馆

-startup
plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.2.R36x_v20101222
-nosplash
org.eclipse.platform
--launcher.XXPermSize
512m
--launcher.XXMaxPermSize
512m
--launcher.defaultAction
openFile
-vm
C:/Program Files (x86)/Java/jrockit-jdk1.6.0_31-R28.2.3-4.1.0/jre/bin
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Xquickstart
-XX:+AggressiveHeap
-XX:+AggressiveOpts
-XX:+UseParallelOldGC
-XX:ParallelGCThreads=2
-XX:ThreadPriorityPolicy=1
-Xverify:none
-Xms1100m
-Xmx1100m

I switched to the 32 bit JRockit JDK which seems a little faster for Eclipse. I turn off and don't install more than I need. For each separate type of app development (Android, J2EE, just Spring, ...) I have different Eclipse installations. Hard drive space is cheap. Then I can have just the plugins I need for each one. I would never want all the Android tools loading if I wasn't using them. STS is also good for just the Spring stuff and I have one just for OpenShift Cloud work.

我切换到 32 位 JRockit JDK,这对于 Eclipse 来说似乎要快一些。我关闭并且不安装超过我需要的。对于每种不同类型的应用程序开发(Android、J2EE、Spring 等等),我都有不同的 Eclipse 安装。硬盘空间很便宜。然后我可以只拥有每个插件所需的插件。如果我不使用它们,我永远不会想要加载所有的 Android 工具。STS 也只适用于 Spring 的东西,我有一个只适用于 OpenShift Cloud 工作。