Eclipse IDE - Improving the memory hog

I stopped using Eclipse IDE quite a while back for a couple of reasons. Firstly, I wanted to explore what other IDE’s were available, and secondly I thought it was a bit of a memory hog. There is nothing worse than having to restart your IDE every couple of hours when you are deep in fixing code.

I downloaded Helios the other day from the PDT Project site which has PHP ready for use. After hunting around, I came across something I thought I’d try, and it made quite a lot of difference in the speed.

Open up the eclipse.ini file inside the eclipse folder (might be best to make a copy of it just in case!). Remove the -Xms40m and -Xmx384m lines from the bottom. Now put this in at the bottom:

-Xms128m
-Xmx512m
-XX:MaxPermSize=120m
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing

Now start Eclipse (or shut it down and restart if you already had it open). Notice any difference?

So.., you may be asking, what does all of this do? The notes below are taken from this garbage collection (GC) article.

Heap size

-Xms256m
-Xmx512m

The more the better…

Perm size

IntelliJ likes a lot of memory for caching references and class meta information. That is why we need to make sure that cache is not purged. Cache is stored in ‘Old Generation’ space which size is determined by the following option

-XX:MaxPermSize=200m

General rule is to observe memory indicator after using find symbol option with include non project files selected. If it doesn’t move you have chosen enough memory.

Maximum Pause

-XX:MaxGCPauseMillis=10

We ask GC to pause the application for no more then 10 milliseconds.

Proportion of free space

-XX:MaxHeapFreeRatio=70

We ask GC to kick off when more than 30% of memory is occupied, so when we start compilation GC will not interfere because it will be enough memory free.

Concurrent Mark-Sweep (CMS) Collector

-XX:+UseConcMarkSweepGC

We want GC to run in parallel with other threads without freezing the application. This option doesn’t stop GC from freezing the application but it reduces it significantly.

Incremental Mode

-XX:+CMSIncrementalPacing

We don’t wont to freeze the application so we do GC incrementally with breaks so the application can take a breath. We use Pacing so GC can learn how to use CPU based on application CPU usage.

Filed under  //   code   development   eclipse   ide   memory   php