35
votes

My eclipse sometimes starts using 100 % of my CPU very spontaneously. I can't figure out why it needs that much CPU usage. There is no background task like "building workspace" running.

After some time the CPU load drops to 0 and everything is normal.

I can't find any information related to the problem in workspace/.metadata/.log file.

Has anybody some tip how I can figure out which part of eclipse is using the CPU so heavily? Is there a way to get a thread dump of eclipse? The kill -3 on the eclipse process doesn't do anything.

Eclipse Version: Galileo JavaEE
Operating System: Linux 2.6.31

5
And you've disabled all plugins? - bitc
Are you sure its eclipse issue only? Are you running any db query from eclipse? While running some heavy queries also you may see 100% CPU usage. - java_enthu

5 Answers

12
votes

Sounds like garbage collection

You could try changing the settings in your eclipse.ini, maybe with a higher Xmx value

--launcher.XXMaxPermSize
256m
-vmargs
-Xms256m
-Xmx1024m
-XX:PermSize=64m
-Xss1M
-server
-XX:+DoEscapeAnalysis
-XX:+UseConcMarkSweepGC
8
votes

You can use visualvm to profile eclipse, get a heap dump or a thread dump, see which threads are running, etc.

6
votes

If anyone else is having this problem, I fixed it for myself. Set the option "auto build project" to off. That should remove a lot of the CPU used by Eclipse.

2
votes

For my installation, I noticed the heap status indicator (Enabled VIA Window>Preferences "Show heap status" under General) was displaying less max heap than allocated in eclipse.ini (the -Xmx setting). The status indicator was bouncing around indicating that garbage collection was struggling to keep memory low.

Increasing the initial/min heap size (the -Xms setting) seems to have caused Eclipse/Java to stop trying to manage memory as much.

2
votes

Eclipse is loading and unloading information from memory whenever this is required. If you workspace is big and you work with multiple projects and also your eclipse is configured to use low ammount of memory this is normal. Someone suggested above to change the xmx and xms values so that your eclipse uses more memory (if you have available) I suggest u put the same value to both of them. For example -Xms4048m and -Xmx4048m (or more) in your eclipse.ini file. This way your system will attempt to make use of that space once you start your IDE and the Garbage Collector (GC) takes less time to process data.