Java. lang. OutOfMemoryError: PermGen space and Its Solution,

Source: Internet
Author: User
Tags xms

Java. lang. OutOfMemoryError: PermGen space and Its Solution,

Recently, an airport project reported an error on the tomcat terminal. Check the log and find that "java. lang. OutOfMemoryError: PermGen space" causes service impact.

The centos 6.5 System

Java 1.7-79

Tomcat apache-tomcat-7.0.79

 

Baidu is searching

PermGen space stands for Permanent Generation space, which refers to the Permanent storage area of the memory OutOfMemoryError: PermGen space is actually out of memory, and the solution must be to increase the memory. This part is used to store Class and Meta information. When the Class is loaded, it is placed in the PermGen space area, which is different from the Heap area where the Instance is stored, GC (Garbage Collection) does not clean up the PermGen space during the main program running period. Therefore, if your APP loads many classes, the PermGen space error may occur. This error is common when the web server pre-compile the JSP. Correction Method:-Xms256m-Xmx256m-XX: MaxNewSize = 256 m-XX: MaxPermSize = 256 m 2. outofmemory error occurs when redeploy in tomcat. there are several possible reasons:
1. Use proxool because proxool contains an earlier version of cglib.
2, log4j, it is best not to use, only use common-logging
3. Update cglib of the old version to the latest version.
4. Update to the latest hibernate3.2. 3,

Take the tomcat environment as an example. Other WEB servers, such as jboss and weblogic, share the same principle.
I. java. lang. outOfMemoryError: The full name of PermGen space is Permanent Generation space, which refers to the Permanent storage area of the memory. This memory is mainly used by JVM to store Class and Meta information, when a Class is loaded, it will be placed in the PermGen space. It is different from the Heap region where the Class Instance is stored. GC (Garbage Collection) permGen space is not cleaned up during the main program running period. Therefore, if your application contains many classes, the PermGen space error may occur, this error is common when the web server pre-compile the JSP. If your web app uses a large number of third-party jar files and the size exceeds the default jvm size (4 MB), this error message is generated.
Solution: manually set MaxPermSize to modify TOMCAT_HOME/bin/catalina. sh Add the following lines to "echo" Using CATALINA_BASE: $ CATALINA_BASE ": JAVA_OPTS ="-server-XX: PermSize = 64 M-XX: MaxPermSize = 128 m
Suggestion: Move the same third-party jar files to the tomcat/shared/lib directory to reduce the memory usage of jar files.
Ii. java. lang. outOfMemoryError: Java heap space Heap size setting the JVM heap setting refers to the setting of the memory space that JVM can allocate during java program running. the JVM automatically sets the Heap size value at startup. The initial space (-Xms) is 1/64 of the physical memory, and the maximum space (-Xmx) is 1/4 of the physical memory. You can use options such as-Xmn-Xms-Xmx provided by JVM to set the configuration. The Heap size is the sum of Young Generation and Tenured Generaion. Tip: if 98% is used for GC and the available Heap size is less than 2% in JVM, this exception is thrown. Tip: the Heap Size should not exceed 80% of the available physical memory. Generally, you must set the-Xms and-Xmx options to the same, and-Xmn to the-Xmx value of 1/4.
Solution: manually set Heap size to modify TOMCAT_HOME/bin/catalina. sh Add the following lines to "echo" Using CATALINA_BASE: $ CATALINA_BASE ": JAVA_OPTS ="-server-Xms800m-Xmx800m-XX: MaxNewSize = 256 m"
Iii. example. For details about java jvm parameter settings in 1 GB memory, see JAVA_OPTS = "-server-Xms800m-Xmx800m-XX: PermSize = 64 M-XX: maxNewSize = 256 m-XX: MaxPermSize = 128 m-Djava. awt. headless = true"

After learning about the information, modify the catalina. sh file in the tomcat bin directory and add the following information:

JAVA_OPTS = "-server-Xms2048m-Xmx2048m-XX: PermSize = 128 m-XX: MaxPermSize = 512 m"

Note: because the server memory is 24 GB enough, set it to 2 GB and modify the above parameter value based on your computer

Restart the tomcat server and verify that the problem is resolved.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.