To have a stable, robust and fast work of AtLeap you should configure your JVM (Java Virtual Machine) properly. JVM configuration is realized by force of passing parameters. For example for Tomcat you should specify CATALINA_OPTS
environment variable, for Resin you should pass it directly into startup script (httpd.exe
or httpd.sh
), for JBoss you should define JAVA_OPTS
environment variable, as for other servlet containers see its documentation.
Let’s examine typical set of JVM arguments
-server
Enable HotSpot Server JIT java compiler. It generates more robust and optimized code, but it slower than HotSpot Client (
-client
option) during compilation. See for more information
http://java.sun.com/docs/hotspot/index.html
http://java.sun.com/products/hotspot/ I recommend use
–client
for development mode and
–server
for production mode.
-Djava.awt.headless=true
You need it to have a correct work of graphics parts if the X server is not installed on Linux.
-Dfile.encoding=UTF-8
Specify it to make sure.
-Xms128m
Specify the initial size, in bytes, of the memory allocation pool (128 megabytes in our case).
-Xmx256m
Specify the maximum size, in bytes, of the memory allocation pool (256 megabytes in our case). It should be between ½ and ¾ of physical memory. It is need to avoid problem OutOfMemoryError. You may also be able to avoid this problem by setting the command-line flags
-Xmx
and
-Xms
to the same value to prevent the VM from trying to expand the heap. Note that simply increasing the value of
-Xmx
will not help when no swap space is available.
-XX:PermSize=64m
Specify the initial size of the permanent generation (where the VM stores the classes and methods data).
-XX:MaxPermSize=128m
Specify the max size of the permanent generation (where the VM stores the classes and methods data). If case of the
-server
option is enabled the default value equal to 64m but in case of
java.lang.OutOfMemoryError: PermGen space
error you should increase this value.
This option does not exist in Bea JRockit and IBM JVMs.
-XX:NewSize=16m
Specify the initial size of the young generation (where the VM stores the short-lived objects).
-XX:MaxNewSize=24m
Specify the maximum size of the young generation (where the VM stores the short-lived objects).
Please carefully read Java documentation for your platform. For example for Solaris it is recommended to specify -XX:-UseLWPSynchronization
option.
If your machine has more than two CPU the following options can be useful: -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled
They allow to enable Concurrent Low Pause Collector.
If your machine has more than two CPU and your Sun JDK 1.5.0_06 or more you can try to use -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseAdaptiveSizePolicy
in order to enable throughput collector.
if you have a IPv6 OS core but need to work with IPv4 addresses specify -Djava.net.preferIPv4Stack=true
If you startup Tomcat under Windows as service you should specify JVM options via Windows registry HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ApacheTomcat\Parameters
(add JVM Option Number N
string value and increase JVM Option Count
).
As result for Linux we can get following line CATALINA_OPTS="-server -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Xms128m -Xmx256m -XX:PermSize=64m -XX:MaxPermSize=128m -XX:NewSize=16m -XX:MaxNewSize=24m"
As for options for Ant you can use e.g. the following line: ANT_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Xms64m -Xmx128m"
Be careful, non-standard JVM options (which begins from -XX:
) can be applied only for Sun's JVM. In order to make tuning of IBM or Bea's JVMs please read documentation.
Below links can be useful during JVM tuning: