Monday, March 3, 2008

Eclipse and Java VM memory tuning

How to improve performance of eclipse instalation ? Well, I'm sure there are lot of posts about this on the internet, but it all narrows down to few steps:
  1. get rid of modules you don't use
  2. tune heap size of JavaVM
  3. tune perm size of JavaVM
Let's look closely at these steps.

1. get rid of unused modules
I like to test new features and modules for eclipse. But after some time I found out that these modules consume lot of memory and increase startup time. You're likely to accept slowdown due to some module that you realy use and it improves your coding. But modules, which you use only ocasionaly should go, or at least you should disable them.

2. tune JavaVM heap size
All objects instantiated during runtime live in heap. Therefore, the more heap you have, more likely all objects will fit there. JavaVM needs to have all of it's VM memory online in physical memory. You can specify maximum size of JavaVM memory with -Xmx<size>. Attempt to allocate more than -Xmx memory will end with OOM exceptions. On the other hand there is -Xms option to JavaVM. With this you specify how much of -Xmx should be directly allocated by JVM. Specifying this to same size as -Xmx means there will be longer startup, but application will run smother.

3. tune JavaVM perm size
The perm memory is the area of the VM, which is used to store data structures and class information. In case you have project with huge amount of classes, JVM may reach the limit of MaxPermSize. Simmiliar with -Xmx and -Xms there are two options:
-XX:PermSize=<size>
-XX:MaxPermSize=<size>

Use -vmargs as parameter to eclipse.exe together with these parameters to tune performance of your eclipse. My values are: -vmargs -Xms256m -Xmx256m -XX:PermSize=64m -XX:MaxPermSize=64m

No comments: