Java stack constant pool

Source: Internet
Author: User

The Java heap holds new objects ( each object contains a corresponding class information, "class information is stored in the method area"), the heap allocates memory, the virtual machine's automatic garbage collector is managed, and the stack memory is only visible to the thread to which it belongs.

The Java stack holds some basic data types (Int,long,byte,double,float,char,boolean,short) and reference variables, and heap memory is visible to all threads.

Exception error

If the stack memory does not have space to store method calls and local variables, the JVM throws Java.lang.StackOverFlowError.
And if the heap memory does not have space available to store the generated objects, the JVM throws Java.lang.OutOfMemoryError.

Space size

The memory of the stack is much smaller than the heap memory, and if you use recursion, your stack will soon be filled. If recursion does not jump out in time, stackoverflowerror problem is likely to occur.
You can set the stack memory size with the-XSS option. The-XMS option sets the size at which the heap starts, and the-XMX option sets the maximum value for the heap.

Method Area:

Also called the static zone, like the heap, is shared by all threads. It is used to store data such as class information, constants, static variables, instant compiler compiled code, etc. that have been loaded by the virtual machine

Java stack constant pool

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.