Resolves an eclipse report PermGen space Memory Overflow exception

Source: Internet
Author: User
Tags xms apache tomcat

The exception issues are as follows:

1. Click Eclipse->window->preferences, as shown below:

2. Click Server->runtime environments, select Apache Tomcat v7.0, and click the Edit button as shown:

3. Select the running JRE, click Installed JREs, as shown in:

4. Select jdk1.7.0_67, click Edit as shown:

5. Locate the default VM Arguments, enter:-xms512m-xmx1024m-xx:maxpermsize=512m in the input box, and then Finish->ok->ok.

Next point to the theory of the Problem: memory overflow type

1. Java.lang.OutOfMemoryError:PermGen Space

The JVM manages two types of memory, heap, and non-heap. The heap is intended for developers, and is created at the start of the JVM, and the non-heap is left to the JVM for its own use to store the information for the class. Unlike heaps, the GC does not free up space during the run time. If the Web app uses a large number of third-party jars, or if the application has too many class files, and the MaxPermSize setting is small, exceeding this will cause the memory to overflow too much, or the Tomcat hot deployment will not clean up the previously loaded environment, Only the context is changed to the newly deployed, and the non-stockpiled content becomes more and more.

PermGen space is the full name of permanent Generation space, refers to the memory of the permanent storage area, this block of memory is mainly stored by the JVM class and meta information, class is loader will be placed in PermGen Space, unlike the heap area where the class instance (Instance) is stored, the GC (garbage Collection) does not clean up permgen space during the main program run time, so if you have a class in your application, PermGen space errors are most likely to occur 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.

One of the best configuration examples: (after I have verified, since the use of this configuration, there is no more tomcat dead situation)

Set java_opts=-xms800m-xmx800m-xx:permsize=128m-xx:maxnewsize=256m-xx:maxpermsize=256m

2.java.lang.outofmemoryerror:java Heap Space

The first case is a supplement, and the main problem is that it appears in this situation. Its default space (that is,-XMS) is 1/64 of physical memory, and the maximum space (-XMX) is 1/4 of physical memory. If the memory is less than 40%,JVM the value of the heap to the XMX setting is increased, the memory remaining more than 70%,JVM will reduce the heap to XMS setting value. So the server's xmx and XMS settings should generally be set identically to avoid resizing the virtual machine heap after each GC. Assuming that the physical memory is infinite, then the maximum size of the JVM memory is related to the operating system, the general 32-bit machine is between 1.5g and 3g, and 64-bit will not be limited.

Note: If XMS exceeds the XMX value, or if the sum of the heap maximum and the non-heap maximum exceeds the physical memory or the maximum operating system limit, the server will not start up.

Role of garbage collection GC

The frequency with which the JVM calls the GC is still high, with garbage collection in two main cases:

When the application thread is idle, and the other is that the Java memory heap is not sufficient, the GC is constantly called, and if continuous recycling does not solve the problem of insufficient memory heap, it will report an out-of-storage error. Because this exception is determined by the operating environment of the system, it cannot be expected when it appears.

According to the GC mechanism, the operation of the program can cause changes in the operating environment of the system and increase the chance of the GC triggering.

To avoid these problems, the design and writing of the program should avoid the garbage object's memory footprint and the GC overhead. The display call System.GC () can only suggest that the JVM needs to recycle garbage objects in memory, but it does not have to be recycled immediately.

One is not able to solve the memory resource depletion situation, but also increase the consumption of GC.

Resolves an eclipse report PermGen space Memory Overflow exception

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.