Java. Lang. outofmemoryerror: permgen Space and Its Solution (keep your own view)

Source: Internet
Author: User
Tags xms

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 PermGen space during the main program running period. Therefore, if your APP loads many classes, PermGen may occur.
Space error. 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 has many classes, PermGen may occur.
Space error, which 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: In JVM, if 98% of the time is used for GC and the Heap is available
This exception is thrown when the size is less than 2%. 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"

Transferred from:Personal space in the mood of midnight

 

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.