Overview
Version
| Resin Version |
|---|
Resin of V4.0.58 or later versions |
Application Scenario
A Java Servlet runs within a web server and shares the same Java Virtual Machine (JVM) as the server. Class loading in the web server consumes memory in the permanent generation (PermGen), while Java application execution, such as retrieving report data and processing intermediate results, consumes heap memory. If the JVM runs out of memory, Out of Memory (OOM) errors may occur, for example, java.lang.OutOfMemoryError:PermGen space or java.lang.OutOfMemoryError:Java heap space.
Function Description
This document describes how to modify the memory settings of the Resin server.
Note: Memory Setting Modification
You (the admin) can modify the memory settings of Resin by editing the resin.xml file. You are advised to modify the following memory-related parameters.
| Parameter | Description | Recommended Value |
|---|---|---|
-Xmx | -Xmx defines the maximum memory size of the Java heap. It sets an upper limit for the Java heap. When the heap reaches the defined size, the JVM stops allocating new memory, and garbage collection is triggered. | 8 GB ≤ -Xmx ≤ 32 GB You can view the recommended on-heap memory size (the -Xmx value) in an inspection report in Health Inspection. |
-Xms | -Xms defines the initial memory size of the Java heap. The JVM allocates memory of the defined size as soon as it starts. | Equal to -Xmx |
-XX:MaxPermSize | -XX:MaxPermSize defines the maximum size of the Permanent Generation (PermGen) memory space, a special memory region in the JVM where metadata about loaded classes, methods, and static variables is stored. | Equal to 1/2 * -Xmx |
-XX:MaxDirectMemorySize | -XX:MaxDirectMemorySize sets an upper limit for the direct memory allocated by Java NIO, which is a common form of off-heap memory. Since the direct memory is allocated from the native memory outside the Java heap, the direct memory size is not limited by the heap size. | 2 GB |
1. Go to Resin installation directory\bin and locate the resin.xml file.
2. Open the resin.xml file with a text editor. Add the following block inside the <cluster id="app"> element to modify the memory setting.
<server-default>
<jvm-arg>-Xms8192m</jvm-arg>
<jvm-arg>-Xmx8192m</jvm-arg>
<jvm-arg>-XX:MaxPermSize=2096m</jvm-arg>
<jvm-arg>-XX:MaxDirectMemorySize=2048m</jvm-arg>
</server-default>
3. Save and close the resin.xml file.
4. Restart the Resin server for the modifications to take effect.
