Java 如何减少 Eclipse Ganymede 的内存使用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/94331/
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
How can I reduce Eclipse Ganymede's memory use?
提问by Dónal
I use the recent Ganymede release of Eclipse, specifically the distro for Java EE and web developers. I have installed a few additional plugins (e.g. Subclipse, Spring, FindBugs) and removed all the Mylyn plugins.
我使用 Eclipse 的最新 Ganymede 版本,特别是 Java EE 和 Web 开发人员的发行版。我已经安装了一些额外的插件(例如 Subclipse、Spring、FindBugs)并删除了所有的 Mylyn 插件。
I don't do anything particularly heavy-duty within Eclipse such as starting an app server or connecting to databases, yet for some reason, after several hours use I see that Eclipse is using close to 500MB of memory.
我没有在 Eclipse 中执行任何特别繁重的工作,例如启动应用程序服务器或连接到数据库,但出于某种原因,在使用几个小时后,我发现 Eclipse 使用了接近 500MB 的内存。
Does anybody know why Eclipse uses so much memory (leaky?), and more importantly, if there's anything I can do to improve this?
有谁知道为什么 Eclipse 使用这么多内存(泄漏?),更重要的是,如果我能做些什么来改进这一点?
回答by Magsol
Eclipse by itself is pretty bloated, and the more plugins you add only exacerbates the situation. It's still my favorite IDE, as it certainly isn't short on functionality, but if you're looking for a lightweight IDE then I'd suggest ditching Eclipse; it's pretty normal to run up half a gig of memory if you leave it running for awhile.
Eclipse 本身非常臃肿,添加的插件越多只会加剧这种情况。它仍然是我最喜欢的 IDE,因为它肯定不缺乏功能,但是如果您正在寻找轻量级 IDE,那么我建议您放弃 Eclipse;如果您让它运行一段时间,那么运行一半的内存是很正常的。
回答by gizmo
Well, you don't specify on which platform this occurs. The memory management may vary if you're using Windows XP, Vista, Linux, OS X, ...
好吧,您没有指定发生在哪个平台上。如果您使用的是 Windows XP、Vista、Linux、OS X 等,内存管理可能会有所不同。
Usually, on my computer (WinXP with 1Gb of Ram), Eclipse take rarely more than 200Mb, depengin of the size of the opened projects, the loaded plugins and the ongoing action.
通常,在我的计算机(带有 1Gb 内存的 WinXP)上,Eclipse 占用的空间很少超过 200Mb,这取决于打开的项目的大小、加载的插件和正在进行的操作。
回答by basszero
RAM is relatively cheap (not that this is an excuse for poor memory managmentment). Unused memory is essentially WASTED memory. If you're hitting limits and the IDE is the problem consider less multitasking, adjusting your memory reqs, or buy more. I wouldn't cripple Eclipse if that's your bread-and-butter IDE.
RAM 相对便宜(并不是说这是内存管理不佳的借口)。未使用的内存本质上是浪费的内存。如果您遇到限制并且 IDE 是问题所在,请考虑减少多任务处理、调整内存需求或购买更多。如果那是您的面包和黄油 IDE,我不会削弱 Eclipse。
回答by Daniel Spiewak
The Ganymede Java EE plugins are absolutely huge when running in memory. Also, I've had bad experiences with FindBugs and its reliability over a long coding session.
Ganymede Java EE 插件在内存中运行时绝对是巨大的。此外,在长时间的编码会话中,我对 FindBugs 及其可靠性有过糟糕的体验。
If you can't live without these plugins though, then your only recourse is to start closing projects. If you limit the number of openprojects in your workspace, the compiler (and FindBugs) will have less to worry about and your memory usage will drop tremendously.
如果你不能没有这些插件,那么你唯一的办法就是开始关闭项目。如果您限制工作区中打开的项目数量,编译器(和 FindBugs)将不必担心并且您的内存使用量将大幅下降。
I usually split up my workspaces by customer and then only keep the bare-minimum projects open within each workspace. Note that if you have a particularly large projects (especially ones with a lot of files checked by WST), that will not only chew through your memory, but also cause a noticeable pause in responsiveness when compiling.
我通常按客户划分我的工作区,然后只在每个工作区中打开最低限度的项目。请注意,如果您有一个特别大的项目(尤其是那些由 WST 检查的大量文件),这不仅会占用您的内存,还会在编译时导致明显的响应暂停。
回答by Daniel Spiewak
Eclipse is a pretty bloated IDE. You can minimize it by turning of the automatic project building under Project -> Build Automatically. It also can be helped by closing any open project you are not currently working on.
Eclipse 是一个相当臃肿的 IDE。您可以通过打开 Project -> Build Automatically 下的自动项目构建来最小化它。关闭您当前未处理的任何打开的项目也可以提供帮助。
回答by Stu Thompson
I'd call it bloated, but not leaky. (If it was leaky it would climb and climb until something crashed.) As others have said, memory is cheap!It seems like a simple decision to me: spend a tiny bit on more memory vs. lose productivity because you don't have the memory budget to run Eclipse @ 500MB.
我会称之为臃肿,但不漏水。(如果它有泄漏,它会一直爬,直到有东西坠毁。)正如其他人所说,内存很便宜!对我来说,这似乎是一个简单的决定:在更多内存上花费一点点而不是失去生产力,因为您没有运行 Eclipse @ 500MB 的内存预算。
Summarized rhetorical question:What is more valuable:
总结性反问:什么更有价值:
- The productivity gained from using an IDE you know with the plug-ins you want, or
- Spending $50-200 on some memory?
- 通过使用您熟悉的 IDE 和您想要的插件而获得的生产力,或者
- 在某些内存上花费 50-200 美元?
回答by Henrik Heimbuerger
I don't think the JVM does a lot of garbage collection unless it has to (i.e. it's getting to its limits). Therefore it grabs all the memory it can get, probably up to the limit set in the eclipse.ini (the -Xmx argument, set to 512MiB here).
我不认为 JVM 会进行大量垃圾收集,除非它必须这样做(即它已达到极限)。因此它会获取它可以获得的所有内存,可能达到 eclipse.ini 中设置的限制(-Xmx 参数,此处设置为 512MiB)。
You can get a visual representation of the current heap status by checking 'Preferences' -> 'General' -> 'Show heap status'. It will create a small gauge in the status bar which also has a 'trash can' button you can use to trigger a manual garbage collection.
您可以通过选中“首选项”->“常规”->“显示堆状态”来获得当前堆状态的可视化表示。它将在状态栏中创建一个小仪表,其中还有一个“垃圾桶”按钮,您可以使用它来触发手动垃圾收集。
回答by Johannes K. Lehnert
I usually give Eclipse 512 MB of RAM (using the -Xmx option of the JVM) and I don't have any memory problems with Ganymede. I upgraded to two GB of RAM a few months ago, and I can really recommend it. It makes a huge difference.
我通常为 Eclipse 提供 512 MB 的 RAM(使用 JVM 的 -Xmx 选项),而且我在使用 Ganymede 时没有任何内存问题。几个月前我升级到了 2 GB 的 RAM,我真的可以推荐它。它制造了巨大的差异。
回答by VonC
Just for information,
仅供参考,
you can add
-Dcom.sun.management.jmxremote
你可以加
-Dcom.sun.management.jmxremote
to your eclise.ini file, launch eclipse and then monitor its memory usage through 'jconsole.exe' found in your jdk installation.
到您的 eclise.ini 文件,启动 eclipse,然后通过 jdk 安装中的“jconsole.exe”监控其内存使用情况。
C:\[jdk1.6.0_0x path]\bin\jconsole.exe
Choose 'Connection / New connection / 'eclipse' to monitor the memory used by eclipse
选择'Connection / New connection /'eclipse'来监控eclipse使用的内存
- always use the latest jvm to launch your eclipse (that does not prevent you to use any other jfk to compile your project within eclipse)
- 始终使用最新的 jvm 来启动您的 eclipse(这不会阻止您使用任何其他 jfk 在 eclipse 中编译您的项目)
回答by GKelly
I don't know about Eclipse specifically, I use IntelliJ which also suffers from memory growth (whether you're actively using it or not!). Anyway, in IntelliJ, I couldn't eliminate the problem, but I did slow down the memory growth by playing with the runtime VM options. You could try resetting these in Eclipse and see if they make a difference.
我不太了解 Eclipse,我使用 IntelliJ,它也受到内存增长的影响(无论您是否积极使用它!)。无论如何,在 IntelliJ 中,我无法消除这个问题,但我确实通过使用运行时 VM 选项减慢了内存增长。您可以尝试在 Eclipse 中重置这些,看看它们是否有所作为。
You can edit the VM options in the eclipse.ini file in your eclipse folder.
您可以在 eclipse 文件夹中的 eclipse.ini 文件中编辑 VM 选项。
I found that (in IntelliJ) the garbage collector settings had the most effect on how fast the memory grows.
我发现(在 IntelliJ 中)垃圾收集器设置对内存增长的速度影响最大。
My settings are:
我的设置是:
-Xms128m
-Xmx512m
-XX:MaxPermSize=120m
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
(See http://piotrga.wordpress.com/2006/12/12/intellij-and-garbage-collection/for an explanation of the individual settings). As you can see, I'm more concerned with avoiding long pauses during editting than actuial memory usage but you could use this as a start.
(有关各个设置的说明,请参阅http://piotrga.wordpress.com/2006/12/12/intellij-and-garbage-collection/)。如您所见,与实际内存使用情况相比,我更关心避免编辑期间的长时间停顿,但您可以将其用作开始。