Welcome to my Tomcat tutorials website!

sabato 10 maggio 2014

How to configure Tomcat JVM parameters

How to increase JVM size in Tomcat

In order to change the JVM heap size for Tomcat, we need to pickup the catalina.sh/catalina.bat file and modify the value for the JAVA_OPTS parameter. For example, suppose we want to change the max heap size from 256 MB to 512 MB while setting the Perm Gen = 256 MB.
Here's how to modify the JAVA_OPTS:

JAVA_OPTS="-Xms128m -Xmx512m -XX:MaxPermSize=256m"

The changes in the JVM settings will take effect on the server restart. You can verify the change done in the JVM parameter by running the jmap command that is part of the JDK distribution. This tool requires passing the processId of Tomcat. Example:

C:\Users\tomcat>jmap -heap 3860
Attaching to process ID 3860, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.51-b03

using thread-local object allocation.
Parallel GC with 4 thread(s)

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 2122317824 (2024.0MB)
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 17592186044415 MB
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 21757952 (20.75MB)
   MaxPermSize      = 85983232 (82.0MB)
   G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 68157440 (65.0MB)
   used     = 54483128 (51.95915985107422MB)
   free     = 13674312 (13.040840148925781MB)
   79.93716900165265% used
From Space:
   capacity = 5242880 (5.0MB)
   used     = 5232656 (4.9902496337890625MB)
   free     = 10224 (0.0097503662109375MB)
   99.80499267578125% used
To Space:
   capacity = 5242880 (5.0MB)
   used     = 0 (0.0MB)
   free     = 5242880 (5.0MB)
   0.0% used
PS Old Generation
   capacity = 88080384 (84.0MB)
   used     = 7874520 (7.509727478027344MB)
   free     = 80205864 (76.49027252197266MB)
   8.940151759556361% used
PS Perm Generation
   capacity = 22020096 (21.0MB)
   used     = 17099528 (16.30738067626953MB)
   free     = 4920568 (4.692619323730469MB)
   77.65419369652157% used

11415 interned Strings occupying 1616648 bytes.
The highlighted line of code in the previous code snippet is reflecting the value changed after the recycle in the JVM parameter.

Nessun commento:

Posta un commento