In this artical we will dscuss about the Sun JVM tunning for JBoss Application Server, Tomcat Web server, Eclipse

-XX Options

Some options may vary per architecture/OS/JVM version. Platforms with a differing default value are listed in the description.
  • Boolean options are turned on with -XX:+<option> and turned off with -XX:-<option>>.
  • Numeric options are set with -XX:<option>=<number>. Numbers can include
    • m or M for megabytes
    • k or K for kilobytes
    • g or G for gigabytes
    • for example, 32k is the same as 32768
  • String options are set with -XX:<option>=<string>, are usually used to specify a file, a path, or a list of commands
Parallel Garbage collection
-XX:+UseParallelGC Use parallel garbage collection for scavenges
-XX:ParallelGCThreads=4 Use parallel garbage collection threads
NOTE: -XX:+UseParallelGC and -XX:+UseConcMarkSweepGC can't be used at same time as JVM Perameter.

Out Of Memory Heap Space

Defining Heap size:
-Xms used for initial java heap size.
-Xmx Used for Maximum java heap size.
Parameter defining bat file of a Server or commandline or eclipse launch file configuration -Xms256M -Xmx512M

java.lang.OutOfMemoryError : PermGen Space

Defining permanent generation (PermGen) space:
-XX:PermSize Used for initial permanent generation size.
-XX:MaxPermSize Used for Maximum permanent generation size.
Parameter defining bat file of a Server or commandline or eclipse launch file configuration -XX:PermSize=256m -XX:MaxPermSize=512
Sweeping of the permanent generation
The Sun JVM uses the permanent generation to store class files, but the permanent generation is not sweeped by the garbage collector. Each time you redeploy your application, the permanent generation gets bigger and eventually it bursts, regardless of how big you make it. The problem is NOT with JBoss AS. You will see the same problem with Tomcat eventually. The problem is with the garbage collector strategy not aligning with how web applications are redeployed. You can enable sweeping of the permanent generation using following parameters.
-XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled
NOTE: IBM JVM does not use a permanent generation (or doesn't use it to store class files). So it does not require any sweeping for the permanent generation.
Dump heap to file when java.lang.OutOfMemoryError
-XX:-HeapDumpOnOutOfMemoryError Dump heap to file when java.lang.OutOfMemoryError is thrown.