JVM memory overflow exception

Source: Internet
Author: User

First, we will briefly introduce some memory setting parameters related to JVM startup. Memory overflow occurs, which is closely related to the settings of these parameters.

Example description:

-Xss128k

The java stack size of each thread. The total size of all stack frames of a thread java stack is 128 kb at the maximum.

-Xms128m

The minimum size of JVM heap (heap memory) is 128 MB and is initially allocated.

-Xmx512m

The maximum size allowed by JVM heap (heap memory) is 256 MB, which is allocated as needed.

-XX: permsize = 20 m

Set the initial size of the Method Area

-XX: maxpermsize = 30 m

Set the maximum value of the method area.

JavaStack Overflow

1. stackoverflowerrorException

The stackoverflowerror exception occurs because the method call level is too deep, and the total size of all stack frames allocated to a thread is greater than the value set by-XSS.

2. outofmemoryerrorException

When Java program code starts a new thread, there is not enough memory space to allocate a java stack to the thread (the size of the java stack of a thread is determined by the-XSS parameter), and JVM throws an outofmemoryerror.

JavaHeap Overflow

Java heap is used to store object instances. When you need to allocate memory for the object instance, and the heap memory usage has reached the maximum value set by-xmx. An outofmemoryerror is thrown.

Method Overflow

The method area stores information about the Java type, such as the class name, access modifier, constant pool, field description, and method description. When the class loader loads the class file to the memory, the virtual opportunity extracts the type information and stores the information to the method area. When class information needs to be stored and the memory usage in the method area has reached the maximum value set by-XX: maxpermsize. An outofmemoryerror is thrown.

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.