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开发者_JS百科 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.31Sounds 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
You can use visualvm to profile eclipse, get a heap dump or a thread dump, see which threads are running, etc.
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.
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.
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.
For me, the solution was to give Eclipse fewer threads. From my really long answer here:
Solution: decrease the max number of threads Eclipse can use, down to 1/2 as many as your computer has. So, if your computer has 8 physical "cores" (actually: hyperthreads), then decrease the max number of threads that Eclipse can use to 4, or <= half of your number of cores for your system, as follows:
In
$HOME/eclipse/cpp-2022-09/eclipse/eclipse.ini
on Linux Ubuntu, or equivalent for your OS, make this change (reducing from 10 threads max, to 4, in my case):Change from:
-Declipse.p2.max.threads=10
to:
-Declipse.p2.max.threads=4
Restart Eclipse.
Now, Eclipse can only take up to 4 of my 8 threads, and my system runs much better!
Read my long answer for more details and other changes I made to help: High CPU usage in Eclipse when idle
精彩评论