Optimize JVM memory to solve outofmemoryerror

Source: Internet
Author: User
Tags xms
Optimize JVM memory to solve outofmemoryerror

From the VM specification, we can see several exceptions.
Java. Lang. stackoverflowerror :( very few)
Java. Lang. outofmemoryerror: heap space (common)
Java. Lang. outofmemoryerror: permgen space (frequently seen)

The following are the most common examples:

    • Java. Lang. outofmemoryerror

Permgen space is a common exception. It refers to the exception overflow in the perm memory area of JVM. Due to the default situation of JVM, perm is 64 MB by default, while manyProgramA large amount of perm memory is required, especially when a framework like spring is used. Because dynamic generation classes are required, these classes cannot be automatically released by GC, resulting in outofmemoryerror: permgen space is abnormal. The solution is simple. Increase the JVM
-XX: maxpermsizeTo solve this problem.

    • Java. Lang. outofmemoryerror

Heap space or other outofmemoryerror. This exception is actually an exception that keeps up with the preceding exception, but the solution is different, so it is written separately. The above exception is caused by the memory difference in the JVM perm zone (JVM memory is divided into three types: young, old, and Perm ). This exception occurs because the JVM heap memory or the overall score is less. The solution is to change
-XMS-xmxThe startup parameter is usually doubled. XMS manages the Minimum Memory volume during startup, and xmx manages the maximum JVM memory volume.

    • Java. Lang. stackoverflowerror

Honestly, I have never met this exception, but the JVM specification mentioned that there are several situations that may throw this exception. One is that when the thread in stacks exceeds the permitted value, the other is when the native method requires a larger memory and exceeds the memory allowed by the native method. According to Sun's documentation-XX: thread stacksize = 512.

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.