Garbage collection
From Resin 3.0
m (Garbage Collection moved to Garbage collection) |
Revision as of 04:08, 14 February 2006
option | description |
---|---|
-J-verbosegc | turn on verbose garbage collection information (recommended) |
-Xmx256m | sets the maximum size of the heap (recommended) |
-XX:MaxPermSize=256m | sets the maximum size of the permanent heap (recommended) |
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.
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.