Resolve PermGen space Tomcat memory settings (RPM)

Source: Internet
Author: User
Tags jboss xms

A Java.lang.OutOfMemoryError exception occurs when you use a Java program to query large amounts of data from a database or an application server (such as Tomcat, jboss,weblogic) loads a jar package. This is mainly due to insufficient memory on the application server. The exceptions are often as follows (for example, for the Tomcat environment, other Web servers, such as Jboss,weblogic, 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 Outofmemoryerror:permgen space. From the text is memory overflow, the solution is to increase the memory. Why memory overflow, this is because the memory is mainly stored by the JVM class and meta information, class is loaded when the PermGen space is placed in the area, it is stored in the instance heap area, GC (garbage Collection) does not clean up permgen space during the main program run time, so if your app will load a lot of classes, it is likely that PermGen space error is occurring. This error is common when the Web server pre-compile the JSP. If you have a large number of third-party jars under your web app that are larger than the JVM's default size (4M), this error message will be generated.
Workaround: Manually set the MaxPermSize size
A. If Tomcat is started in bat mode, the following settings are set:
Modify Tomcat_home/bin/catalina.sh
Add the following line to the "echo" Using catalina_base: $CATALINA _base "":
Java_opts= "-server-xx:permsize=64m-xx:maxpermsize=128m
B. If Tomcat is registered as a Windows service and started in services, you need to modify the corresponding key values in the registry.
Open the registry, locate the directory Hkey_local_machine\software\apache software Foundation\procrun 2.0\htfty\parameters\java, The red label in the directory address (such as htfty) needs to be modified according to different circumstances to register the Tomcat service as the name of the Windows service. You can see the Jvmms and jvmmx entries, where Jvmms sets the minimum memory usage parameters, JVMMX sets the maximum memory usage parameters. Set the values of the Jvmms and JVMMX entries and restart the Tomcat server to take effect.
Recommendation: Move the same third-party jar files to the Tomcat/shared/lib directory, which can reduce the memory consumption of the jar document.
2. Java.lang.OutOfMemoryError:Java Heap Space
The JVM heap setting is the set of memory space that the JVM can provision in the course of running the Java program. The JVM automatically sets the value of the heap size when it starts, and its initial space (that is,-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 the-XMN-XMS-XMX provided by the JVM to set it up. The size of Heap size is the sum of young Generation and tenured generaion. This exception information is thrown in the JVM if 98% of the time is used for GC and the available heap size is less than 2%.
Workaround: Manually set the heap size
A. If Tomcat is started in bat mode, the following settings are set:
Modify Tomcat_home/bin/catalina.sh
Add the following line to the "echo" Using catalina_base: $CATALINA _base "":
Java_opts= "-server-xms800m-xmx800m-xx:maxnewsize=256m"
B. If Tomcat is registered as a Windows service and started in services, you need to modify the corresponding key values in the registry.
Open the registry, locate the directory Hkey_local_machine\software\apache software Foundation\procrun 2.0\htfty\parameters\java, The red label in the directory address (such as htfty) needs to be modified according to different circumstances to register the Tomcat service as the name of the Windows service. You can see the Jvmms and jvmmx entries, where Jvmms sets the minimum memory usage parameters, JVMMX sets the maximum memory usage parameters. Set the values of the Jvmms and JVMMX entries and restart the Tomcat server to take effect.
Tip: The Heap Size does not exceed 80% of the available physical memory, generally the-XMS and-XMX options are set to the same, and the-XMX value of-xmn is 1/4.

Resolve PermGen space Tomcat memory settings (RPM)

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.