Tomcat Memory Overflow Summary

Source: Internet
Author: User
Tags garbage collection tomcat xms

The Tomcat memory settings in the production environment are not good enough to overflow the memory. The memory cause is not the same, of course, the processing is not the same.

Here according to the usual situation and related information to carry out a summary. Common in the following three kinds of situations generally:

1.outofmemoryerror:java Heap Space

2.outofmemoryerror:permgen Space

3.outofmemoryerror:unable to create new native thread.

For the first two cases, you can use the set tomcat JVM parameter to resolve the application itself without a memory leak. (-xms-xmx-xx:permsize-xx:maxpermsize)

The last one may need to adjust the operating system and tomcat JVM parameters while adjusting to achieve the goal.

The first: Heap overflow.

This exception information is thrown in the JVM if 98% of the time is for GC and the available HEAP size is less than 2%.

If there is no memory leak, the adjustment-xms-xmx parameter can be resolved.

-XMS: initial Heap Size

-XMX: Maximum Heap Size

However, the size of the heap is affected by the following three factors:

1. The data model of the relevant operating system (32-BT or 64-bit) is limited; (32-bit system, generally limited to the 1.5g~2g; I am under 2003 Server System (physical memory: 4G and 6g,jdk:1.6) test 1612m,64 is unlimited memory for the operating system. )

2. The system's available virtual memory limits;

3. The system's available physical memory limits.

The size of the heap can be tested using the JAVA-XMX***M version command. Support will appear in the JDK version number, does not support the error.

-XMS-XMX is generally configured to be as good as the set java_opts=-xms1024m-xmx1024m

The second type: Persistent save area overflow

PermGen space is the full name of the permanent Generation spaces, refers to the permanent storage area of memory. This section is used to store class and meta information, class is placed in the PermGen space area when it is load, and is different from the heap area where instance is stored, GC (garbage Collection) PermGen space will not be cleaned up during the main program run, so if your app will load a lot of classes, PermGen space error is likely to occur. This error is common when the Web server is pre compile the JSP. But this is also easy to do in the current Hibernate and spring projects. Http://www.javaeye.com/topic/80620?page=1 's post has a discussion on this issue. This may be because these frameworks are dynamic class, and the JVM's GC does not clean up the Pemgen space, resulting in a memory overflow.

This one is usually to increase-xx:permsize-xx:maxpermsize to solve the problem.

-xx:permsize Permanent Save Area Initial size

-xx:permsize permanently saves the initial maximum value of the area

This is generally combined with the first one, such as set java_opts=-xms1024m-xmx1024m-xx:permsize=128m-xx:permsize=256m

One thing to note: The java-xmx***m version command to test the maximum heap memory is-xmx with-xx:permsize and for example the system supports the largest JVM heap size thing 1.5G, that-xmx1024m-xx:permsize=768m is not able to run.

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.