tomcat PermGen space

Java.lang.outofmemoryerror exception will appear when Java program is used to query a large amount of data from database or when application server (such as tomcat, JBoss, Weblogic) loads jar package. This is mainly due to the lack of memory in the application server. This kind of exception often has the following situations (take Tomcat environment as an example, other web servers such as JBoss, Weblogic, etc. are the same truth as the following ones)

1. java.lang.OutOfMemoryError: PermGen space

The full name of permgen space is permanent generation space, which refers to the memory persistent area outofmemoryerror: permgen space. From the text point of view is memory overflow, the solution is to increase memory. Why is there a memory overflow?This memory is mainly used by the JVM to store class and meta information. When the class is loaded, it is put into the permgen space area. It is different from the heap area where the instance is stored. GC (garbage collection) will not clean up the permgen space during the main program running period, so if your app will load many classes, The permgen space error is likely to occur. This kind of error is common when the web server pre compiles the JSP. If a large number of third-party jars are used in your web app, and their size exceeds the default size of the JVM (4m), then this error message will be generated
solution: set maxpermsize manually

A. if Tomcat is started in bat mode, the settings are as follows: a

Modify Tomcat_ Home/bin/Catalina. Sh
in echo “using Catalina_ BASE: $CATALINA_ Add the following line to “base”:
java_ OPTS=”-server -XX:PermSize=64M -XX:MaxPermSize=128m”

B. If Tomcat is registered as a Windows service and started as services, you need to modify the corresponding key value in the registry

Open the registry and find the directory HKEY_ LOCAL_ Machine, software, Apache Software Foundation, procrun 2.0, htfty, parameters, Java. The red marked in the directory address (such as htfty) needs to be modified according to different situations to register the Tomcat service as the name of the windows service. You can see the jvmms and jvmmx items, where jvmms sets the minimum memory usage parameter and jvmmx sets the maximum memory usage parameter. Set the values of jvmms and jvmmx, and restart Tomcat server to take effect
suggestion: move the same third-party jar files to Tomcat/shared/lib directory, so as to reduce the repeated memory occupation of jar documents

2. java.lang.OutOfMemoryError: Java heap space

The setting of JVM heap refers to the setting of memory space that can be allocated and used by JVM during Java program running. When the JVM starts up, it will automatically set the value of heap size. The initial space (- XMS) is 1/64 of the physical memory, and the maximum space (- Xmx) is 1/4 of the physical memory. The – XMN – XMS – Xmx and other options provided by the JVM can be used for setting. The size of heap size is the sum of young generation and tenured generation. In the JVM, if 98% of the time is spent on GC and the available heap size is less than 2%, this exception will be thrown
solution: manually set the heap size
value

A. if Tomcat is started in bat mode, the settings are as follows: a

Modify Tomcat_ Home/bin/Catalina. Sh
in “echo” using Catalina_ BASE: $CATALINA_ Add the following line to the “base”:
java_ OPTS=”-server -Xms800m -Xmx800m -XX:MaxNewSize=256m”

B. If Tomcat is registered as a Windows service and started as services, you need to modify the corresponding key value in the registry

Open the registry and find the directory HKEY_ LOCAL_ Machine, software, Apache Software Foundation, procrun 2.0, htfty, parameters, Java. The red marked in the directory address (such as htfty) needs to be modified according to different situations to register the Tomcat service as the name of the windows service. You can see the jvmms and jvmmx items, where jvmms sets the minimum memory usage parameter and jvmmx sets the maximum memory usage parameter. Set the values of jvmms and jvmmx, and restart Tomcat server to take effect

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 value, while – XMN should be 1/4 of the – Xmx value

Original text: http://www.cnblogs.com/afarmer/archive/2012/01/05/2313283.html

This article is from the CSDN blog of paradise on the left. Please click: https://blog.csdn.net/tiantang_ 1986/article/details/76977635?utm_ source=copy

Similar Posts: