Friday, July 31, 2009

JVM Tuning

As a Java developer we come across various applications where Sun JVM is used in production environment. One of the most common and unresolved error in Production environment would be Java's "OutOfMemoryError". Application tries to do something which is memory intensive and suddenly JVM reports the error. Most of the guys would tell you to increase the heap size for the JVM. Unfortunately, Sun's JVM cannot be started with more 1GB of maximum heap space even if the system has enough memory available to allocate. Yes, it is quite surprising that even if system has 4GB RAM available but yet JVM cannot be allocated more than 1GB RAM. I recently ran into a similar issue where my application was deployed under Tomcat 5.5.23 and had maximum heap size set to 1GB. System had 4GB of RAM available. I increased maximum heap size from 1 GB to 2GB but then Tomcat never started. JVM was unable to create heap space! I did lot of search and finally taking clue from somewhere I switched my JVM from Sun's JVM to Oracle JRockit and now I was able to run Tomcat with 2GB of maximum heap space. It is quite shocking to know that Sun's JVM doesn't support more than 1GB of Max heap size and JRockit does.

Has Sun missed out on something?

- Jignesh Satra