36

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

Kai
  • 38,985
  • 14
  • 88
  • 103
Florian Gutmann
  • 2,666
  • 2
  • 20
  • 28
  • And you've disabled all plugins? – bitc Apr 21 '10 at 10:20
  • 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 Dec 28 '11 at 14:55
  • 12 years later (with version 2022-06) one can still run into this problem! As mentioned in comments of the accepted answer, the keypoint was the `ConsolePatternMatcher$MatchJob` for a huge console output! There were several bugs for this in eclipse's bugzilla, but once the console output goes over a certain size, any regex operations (especially greedy ones) do become risky I guess! Wish there were options to disable these "jobs" for console scanning (or action buttons to cancel them once it starts - as in "Progress" view (even though cancelling there also fails more ofen than it works! :) ) – OzgurH Jul 31 '22 at 19:51
  • I went a bit further on that wish of mine in the comment above added some notes to the most relevant bug I can find in eclipse's bugzille: [#492461](https://bugs.eclipse.org/bugs/show_bug.cgi?id=492461) - chime in there if you'd like some action to be taken on this problem. – OzgurH Jul 31 '22 at 19:57
  • See also: [High CPU usage in Eclipse when idle](https://stackoverflow.com/q/11346357/4561887) – Gabriel Staples Dec 06 '22 at 17:43

6 Answers6

13

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
stacker
  • 68,052
  • 28
  • 140
  • 210
  • 4
    Turning on the General preferences option "Show heap status" can also help to determine whether garbage collection is the cause. – Stephen Denne Apr 21 '10 at 10:26
  • 1
    I already started eclipse with a lot of memory (permsize 128 mb and 1024 mb heap). Also the cpu usage is up to 100 % for too long if it only were garbage collection. – Florian Gutmann Apr 21 '10 at 10:32
9

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

Stephen Denne
  • 36,219
  • 10
  • 45
  • 60
  • Wow! I didn't know visualvm before it looks very promising and i think i got a hint to the right direction. Thanks a lot! – Florian Gutmann Apr 21 '10 at 11:09
  • @Florian were you able to determine what was using the CPU? – Stephen Denne Apr 21 '10 at 22:47
  • I thought so, but later found out that it wasn't the php plugin. But now i have a good tool to track down the issue. – Florian Gutmann Apr 22 '10 at 07:29
  • 3
    Finally i could really track it down. Now I'm 99% sure what causes the load. It's a regular expression invoked by `org.eclipse.ui.internal.console. ConsolePatternMatcher$MatchJob.run(ConsolePatternMatcher.java:127)`. When i tried to clear the console output eclipse got totally unresponsive. I will try to collect some more information about the issue (like the console output) and go for the eclipse mailing list. Thanks again Stephen! – Florian Gutmann Apr 22 '10 at 08:51
  • Hi, I can't get VisualVM to get a thread dump of Eclipse (STS in this case). It says it cannot connect to Eclipse's JMX. Could you please explain to me how are you able to do a thread dump of Eclipse? Thanks! – Luciano Jun 02 '11 at 15:52
  • @Luciano You should ask that as a new question. – Stephen Denne Jun 07 '11 at 01:01
5

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.

daboross
  • 716
  • 10
  • 23
  • The whole point of eclipse is to automate development build workflow. Auto-build is only invoked on write. It does not poll, and therefore cannot thrash the CPU. – Dominic Cerisano Jul 21 '17 at 15:42
  • 2
    @DominicCerisano I've actually seen eclipse setups (bloated with many plugins) where auto build often goes in to some kind of loop and is executed every few seconds. It's not a common problem though, usually auto build should not cause issues like this. – kapex Oct 24 '17 at 14:10
  • Even without plugins, if you're on a low-power laptop compiling on every write / file save can be a bit much. – daboross Oct 24 '17 at 20:24
  • @kapep then those plugins are looping while touching a file - not auto-build. OP - Eclipse does have minimum specs. Running without auto-build will lead to poor workflow. – Dominic Cerisano Oct 28 '17 at 19:54
  • 2
    @Dominic Cerisano Even so - there are situations where plugins are required, or you're running on a computer below the minimum spec where disabling autobuild will speed it up. I don't claim this answer is the best, only that it did solve a problem I was having that wasn't solved by anything else. – daboross Oct 28 '17 at 23:49
  • Disabling the core function of eclipse (auto-build) is not a solution. I gave two other solutions - firstly, don't use plugins that break auto-build, and secondly, observe the minimum specs. – Dominic Cerisano Oct 31 '17 at 21:21
  • 2
    @DominicCerisano Yes, those are two valid solutions. How does their existence invalidate a third solution which can be used when neither of them can? – daboross Nov 01 '17 at 01:14
  • @DominicCerisano "don't use those plugins" may work in a hobby project but unfortunately I actually need those plugins to do my work. Of course the other solutions are better, no one said otherwise. But this work-around is the only solution one that works for me. (and since it only happened in certain rare situations it is an acceptable solution to me) – kapex Nov 01 '17 at 09:31
  • @Kapep I would fire anyone who disables auto-build in favour of some poorly designed plugin that borks Eclipse workflow (IMHO most plugins are hobby projects). Also please don't misquote me - use single quotes if you wish to paraphrase. – Dominic Cerisano Nov 02 '17 at 04:12
  • @DominicCerisano Yeah but I hope you understand that _other people_ are more likely to fire anyone who doesn't deliver results because they refuse to use an inconvenient but simple workaround. Of course it's better to have the plugins fixed but that's not always feasible within given project deadlines and budget. Sorry about messing up the quote, that wasn't intentional. – kapex Nov 02 '17 at 13:42
  • If a workaround involves gimping Eclipse workflow, the result is going to be slipped deadlines. That is inconvenient to clients - hence the risk of termination. Better just to avoid pretty plugins that are not ready for prime time, and prioritise your workflow. Apology accepted. – Dominic Cerisano Nov 02 '17 at 20:12
  • For what it's worth I found this problem today, bringing my sufficiently well specced machine to its knees (8 cores at 100 CPU, 32 GB RAM not much used, Intel Core i7-4790 processor) and disabling auto build fixed it. I'm using PyDev and Mylyn and not much else, and always have, and if any of the smart folk who prefer to avoid faulty plugins know how to identify one, speak up please! – Bernd Wechner Jan 27 '20 at 10:12
2

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.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
tuckerpm
  • 191
  • 1
  • 1
  • 10
2

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.

theo231022
  • 329
  • 2
  • 12
0

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

Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265