Garbage collection
From Resin 3.0
m (Garbage Collection moved to Garbage collection) |
|||
Line 1: | Line 1: | ||
[[Category:Memory]] [[Category:Troubleshooting]] | [[Category:Memory]] [[Category:Troubleshooting]] | ||
− | + | Configuration of the memory parameters for the JVM is accomplished by adding <jvm-arg> options in resin.conf that are passed to the JVM when the server is started. The default values for both the maximum heap size and the maximum permanent heap area are too low. It is recommended to increase both values. | |
− | + | ||
− | + | in resin.conf: | |
− | + | ||
− | + | <!-- verbose garbage collection --> | |
− | + | <jvm-arg>-verbose:gc</jvm-arg> | |
− | + | <jvm-arg>-XX:+PrintGCTimeStamps</jvm-arg> | |
− | + | <jvm-arg>-XX:+PrintGCDetails</jvm-arg> | |
− | + | ||
+ | <!-- memory settings --> | ||
+ | <jvm-arg>-Xmx256m</jvm-arg> <!-- sets the maximum size of the heap (recommended) --> | ||
+ | <jvm-arg>-XX:MaxPermSize=256m</jvm-arg> <!-- sets the maximum size of the permanent heap (recommended) --> | ||
− | |||
==MaxPermSize== | ==MaxPermSize== |
Revision as of 19:46, 8 April 2008
Configuration of the memory parameters for the JVM is accomplished by adding <jvm-arg> options in resin.conf that are passed to the JVM when the server is started. The default values for both the maximum heap size and the maximum permanent heap area are too low. It is recommended to increase both values.
in resin.conf: <!-- verbose garbage collection --> <jvm-arg>-verbose:gc</jvm-arg> <jvm-arg>-XX:+PrintGCTimeStamps</jvm-arg> <jvm-arg>-XX:+PrintGCDetails</jvm-arg> <!-- memory settings --> <jvm-arg>-Xmx256m</jvm-arg> <!-- sets the maximum size of the heap (recommended) --> <jvm-arg>-XX:MaxPermSize=256m</jvm-arg> <!-- sets the maximum size of the permanent heap (recommended) -->
MaxPermSize
The MaxPermSize - the maximum size for permanent objects in the heap - is a separate space from the heap size specified by -Xmx. Several Resin users have found excessive garbage collection times even when there is plenty of heap space available as reported by -J-verbosegc. In many of these cases, increasing the MaxPermSize solves the issue.
Because MaxPermSize is a maximum size, it is safe to increase its value even if you do not know if your application will actuall need that space.
Solving excessive garbage collection times
The first step for troubleshooting garbage collection issues is to enable -J-verbosegc or something similar in a debugging tool to get an idea of what the JVMs garbage collection is doing.
Make sure both -Xmx and -XX:MaxPermSize are large enough. If the debugging output shows a large number of "FullGC" but there appears to be enough heap space, then the MaxPermSize should probably be increased.
If a Full GC is taking an excessively long time, then check to make sure that the JVM heap is not being swapped to disk by the operating system. A Full GC freezes the entire applicaiton in the JVM while the Full GC is performed. If some portion of the JVM heap is swapped to disk, the Full GC will cause it to be swapped back in. Well tuned server environments have no portion of the JVM heap swapped to virtual memory on the disk.