Several cases of memory overflow in Java heap (RPM)

Source: Internet
Author: User
Tags gc overhead limit exceeded

"Situation one":    Java. lang. Outofmemoryerror:java Heap Space: This is not enough Java heap memory, one reason is not enough, another reason is that there is a dead loop in the program, if the Java heap memory is not enough, you can adjust the JVM under the configuration to solve: < Jvm-arg>-xms3062m</jvm-arg> <jvm-arg>-Xmx3062m</jvm-arg> "Situation two"Java.lang.OutOfMemoryError:GC overhead limit Exceeded "explanation": the JDK6 new error type, which is thrown when the GC takes up a lot of time to free up small space, usually because the heap is too small, causes the exception, and does not have enough memory. "Solution": 1, to see if the system has the use of large memory code or a dead loop, 2, by adding a JVM configuration, to limit the use of memory: <jvm-arg>-XX:-UseGCOverheadLimit</jvm-arg> "Situation three":Java.lang.OutOfMemoryError:PermGen space: This is P-zone memory is not enough, can be adjusted by the JVM configuration: <jvm-arg>-xx:maxpermsize=128m</jvm-arg > <jvm-arg>-XXermSize=128m</jvm-arg> "Note": the perm area of the JVM is primarily used to store class and meta information, and class is placed in the PermGen when it is loader Space, this area become old generation, GC in the main program during the run will not clean up the old area, the default is 64M size, when the program needs to load more than a few objects, more than 64M will be reported this part of memory overflow, need to increase memory allocation, general 128m enough. "Situation four":Java.lang.OutOfMemoryError:Direct buffer Memory Adjusts the-xx:maxdirectmemorysize= parameters, such as adding a JVM configuration: <jvm-arg>-xx: Maxdirectmemorysize=128m</jvm-arg> "Situation five":Java.lang.OutOfMemoryError:unable to create new native thread "cause": stack space is not enough to create additional threads, either there are too many threads created, or the stack space is indeed small. "Resolution": Because the JVM does not provide parameters to set the total stack space size, but can set the size of a single line stacks, and the system's user space is 3G, in addition to text/data/bss/memorymapping a few paragraphs, heap and stack space is limited , it is the elimination of the other long. Therefore, there are two ways to solve this error: 1. Reduce the size of a single thread stack by-XSS startup parameters, so that more threads can be opened (not too small, too small to appear stackoverflowerror), 2. Reduce the heap size by-xms-xmx two parameters, Give the memory to the stack (provided that the heap space is sufficient). "Situation six":Java.lang.StackOverflowError "Cause": This is also a memory overflow error, that is, the overflow of the line stacks, either the method call hierarchy too many (such as there is an infinite recursive call), or the line stacks is too small. "Solve": Optimize the program design, reduce the method call level, adjust the-XSS parameter to increase the thread stack size. http://tomcat-oracle.iteye.com/blog/2187063

Several cases of memory overflow in Java heap (RPM)

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.