Well, it all depends on the size of your project and the plugins that you use. Allocate too little and Java Garbage Collector will consume a lot of CPU going through the heap trying to remove discarded objects to make room for new ones, allocate too much than you system has free (available) and it will swap extensively to disk (“swap” file) to give you more free RAM.
How would you know if you allocated enough to Eclipse or you might need to allocate more (provided that you see you have the free memory available). This is where Eclipse “show heap status” feature comes in handy.
First of all you need to enable it: Windows > Preferences > General > Show heap status. It will show this little graph in the status bar:
- left area (lighter) is how much heap it uses at the moment.
- right area (darker if you right-click it and check show “Heap Max”) is how much is available from what pre-allocated (either through –Xms startup parameter or pushed past –Xms towards –Xmx)
- hover to get the details in a tooltip;
- click the garbage can to force a Garbage Collection.
Then look at it while using the project (build etc) – if the heap usage goes towards maximum, the colour will turn red showing that it might be struggling. You can force a garbage collection using the “garbage can”, but that’s a workaround just to finish the job instead of having to restart Eclipse. Use it too much and the JVM will pause to force an early GC.
In my example I have both minimum (-Xms) and maximum (-Xmx) heap size set to the same values (384MB) and at that moment was only using 41 MB out of it (it pre-allocated though the minimum from the system at startup). As you will be using the project it will go up and down, as needed and as GC will do it’s job.
[...] --launcher.XXMaxPermSize 256M [...] -vm C:\Program Files\Java\jdk1.7.0_09\jre\bin\server\jvm.dll -vmargs [...] -Xms384m -Xmx384mSo why is my eclipse.exe (javaw.exe) process using 600 MB of RAM when I’ve set my heap to 384 MB? It’s because Heap is not everything, there’s also the Permanent Generation (PermGen) and a few other things, so consider those as well when you decide to increase heap. On Windows use a tool like Process Explorer to see all these details – system commit, free RAM, process private bytes, working set etc.