Increased memory failures for TOMCAT

Taking the tomcat environment as an example, other WEB servers such as jboss, weblogic, etc. are the same.
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 Meta information, and Class will be placed when it is loaded by Loader. In the PermGen space,
it is different from the Heap area where the class instance (Instance) is stored. GC (Garbage Collection) will not
clean up the PermGen space during the main program runtime, so if your application has a lot of CLASS, it is very likely A PermGen space error occurs,
which is 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.
Solution: Manually set the MaxPermSize size

Modify TOMCAT_HOME/bin/catalina.sh
and add the following line above "echo "Using CATALINA_BASE: $CATALINA_BASE"":
JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128M"
Suggestion : Move the same third-party jar file to the tomcat/shared/lib directory, so as to reduce the repeated occupation of memory by the jar file.

2. java.lang.OutOfMemoryError: Java heap space
Heap size Setting 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 The space (i.e. -Xms) is 1/64 of the physical memory, and the maximum space (-Xmx) is 1/4 of the 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 TOMCAT_HOME/bin/catalina.sh and
add the following line above "echo "Using CATALINA_BASE: $CATALINA_BASE"":
JAVA_OPTS="-server -Xms800m -Xmx800m -XX:MaxNewSize=256m"

Guess you like

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