Memory parameter tuning Tomcat project

A common Java memory overflow has the following three:
 1. Java.lang.OutOfMemoryError: Java heap Space That JVM Heap Overflow

Explanation: JVM JVM Heap will automatically set the value at the time of startup, JVM heap setting refers to the setup process is running java program can be deployed using the JVM memory space. The default initial physical memory space 1/64, not exceed the maximum physical memory space. -Xmn -Xms -Xmx JVM offers other options to be set.

Error Scene: In the JVM, if 98% of the time for the GC, and available Heap size less than 2%, there will be an overflow JVM Heap

Solution: Modify the size of the JVM Heap.

2.java.lang.OutOfMemoryError: PermGen space i.e. PermGen space overflow 
explanation: PermGen space refers to the permanent memory storage area. This area is mainly stored Class and Meta information, Class PermGen space will be placed when Load.
Error scenario: If you load a lot of APP CLASS, may PermGen space overflow occurs. (Because the sun will not clean up the GC to PermGen space at runtime) is common in web server when the JSP to pre compile

Solution: Modify MaxPermSize size 
3. java.lang.StackOverflowError ie stack overflow

Explanation: JVM uses a stack type of virtual machine, calls the process function are reflected on the stack and unstack.

Error scenario: usually stack size is 1-2MB, if too many "layers" call the constructor, stack overflow occurs

Two, the JVM Tomcat memory overflow solution 
in a production environment, tomcat is prone to bad memory settings JVM memory overflow, the solution is to modify the file catalina.sh in Tomcat. 
In catalina.sh file, found cygwin = false, this line was added in front of the parameters, as follows

$ vim TOMCAT_HOME/bin/catalina.sh

JAVA_OPTS=”-server -Xms800m -Xmx800m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:MaxNewSize=512m”

Other notes: 
1. "m" indicate units of MB, otherwise default KB 
2. 80% is generally used as the physical memory heap size 
3. General -Xms and -Xmx set to as large as 
4 is set to generally the -Xmn -Xmx value 1/4 
5. Usually 50% to 60% of the total size of the heap assigned to a pool of new generation

Three, jvm parameters Description: 
-server as the first argument must enable the server version of the JDK, good CPU performance when multiple 
-Xms java Heap initial size. The default is the physical memory of 1/64. 
-Xmx java heap maximum. Recommendations are set to 80 percent of physical memory. Not exceed the physical memory. 
-Xmn java heap minimum value, typically set to one of Xmx 3,4 points. 
-XX: setting initial size PermSize permanent memory storage area defaults 64M. 
-XX: The maximum size of permanent preservation area set MaxPermSize memory, default is 64M. 
-XX: SurvivorRatio = 2 survivors pool size, the default is 2. The 
-XX: NewSize initial size of the newly generated cell. The default is 2M. 
-XX: The maximum size of the newly generated MaxNewSize pool. The default value is 32M. 
+ XX: AggressiveHeap let jvm ignored Xmx parameters, frantically eating a G physical memory, and then suffered a swap of G. 
Stack -Xss each thread size 
-verbose: gc reality garbage collection information 
-Xloggc: gc.log designated garbage collection log file 
-XX: + UseParNewGC shorten the time minor collection 
-XX: + UseConcMarkSweepGC shorten time major collection 
-XX: userParNewGC used to set the parallel collector (multiple CPU) 
-XX: ParallelGCThreads used to increase the degree of parallelism (multiple CPU) 
-XX: After setting UseParallelGC sweep collector may be used in parallel (Multi-CPU)

Guess you like

Origin www.cnblogs.com/huangjinyong/p/11794057.html