Tomcat JVM memory configuration under Linux

http://elf8848.iteye.com/blog/467460


CATALINA_OPTS="$CATALINA_OPTS -server -Xms1536m -Xmx1536m -XX:PermSize=256m -XX:MaxPermSize=256m"

There are two common memory overflows:
java.lang. OutOfMemoryError: PermGen space
java.lang.OutOfMemoryError: Java heap space

1. java.lang.OutOfMemoryError: PermGen
space The full name of PermGen space is Permanent Generation space, which refers to the permanent storage area of ​​memory.
This memory is mainly used by JVM to store Class and For the Meta information, the Class will be placed in the PermGen space when it is loaded by the Loader.
It is different from the Heap area where the class instance (Instance) is stored. The GC (Garbage Collection) will not
clean up the PermGen space during the runtime of the main program, so If you have a lot of CLASS in your application, it is very likely to have PermGen space errors,
which are common when the web server precompiles the JSP. If your WEB APP uses a lot of third-party jars, the size of which
exceeds the default size of jvm (4M), then this error message will be generated.
Workaround: Manually set the MaxPermSize size
Suggestion: Move the same third-party jar files to the tomcat/shared/lib directory, so as to reduce the memory occupied by the jar files.

2. java.lang.OutOfMemoryError: Java heap space
The setting of the JVM heap refers to the setting of the memory space that the JVM can allocate and use during the running of the java program. The JVM will automatically set the value of the Heap size when it is started, and
its initial space (ie -Xms) is 1/64 of physical memory, and the maximum space (-Xmx) is 1/4 of physical memory. It can
be . The size of Heap size is the sum of Young Generation and Tenured Generation.
Hint: This exception will be thrown if 98% of the time in the JVM is used for GC and the available Heap size is less than 2%.
Tip: The maximum Heap Size should not exceed 80% of the available physical memory. Generally, the -Xms and -Xmx options should be set to the same, and -Xmn is 1/4 of the -Xmx value.
Solution: Manually set the Heap size


------------ Modify the TomcatJVM memory size under Linux --------------- -------
To be added in catalina.sh under the bin of tomcat, before the location cygwin=false. Note that the quotation marks should be put on, and the red ones are newly added.
# OS specific support. $var _must_ be set to either true or false.
JAVA_OPTS="-Xms256m -Xmx512m -Xss1024K -XX:PermSize=128m -XX:MaxPermSize=256m"
cygwin=false

------------Modify under windows Tomcat JVM memory size ------------
Scenario 1: The decompressed version of Tomcat, you need to start tomcat through startup.bat to load the configuration
to be added to the bin of tomcat In catalina.bat, add
rem Guess CATALINA_HOME if not defined
set CURRENT_DIR=%cd%, and the red ones are newly added.
set JAVA_OPTS=-Xms256m -Xmx512m -XX:PermSize=128M -XX:MaxNewSize=256m -XX:MaxPermSize =256m -Djava.awt.headless=true

Case 2: The installed version of Tomcat does not have catalina.bat

under the installed version of Tomcat.
If tomcat 6 is registered as a windows service, or the installed version of tomcat is used under windows2003,
in It can be modified in /bin/tomcat6w.exe.

If tomcat 5, the windows service executes bin\tomcat.exe. It reads the value in the registry, not the setting of catalina.bat.
Modify the registry HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Tomcat Service Manager\Tomcat5\Parameters\JavaOptions
to
-Dcatalina.home="C:\ApacheGroup\Tomcat 5.0" -Djava.endorsed.dirs
="C:\ApacheGroup\ Tomcat 5.0\common\endorsed"
-Xrs
join -Xms300m -Xmx350m
restart the tomcat service, the settings will take effect

----------------------- ----------------------------
The ratio of each parameter:
The sum of Xmx and PermSize cannot exceed the total memory available to the JVM
PermSize cannot be greater than Xmx
Please refer to other articles for detailed explanation of parameters, the value of each parameter is not discussed in this article.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326990700&siteId=291194637