Java stack constant pool and java constant pool

Source: Internet
Author: User

Java stack constant pool and java constant pool

JavaHeap(Each object contains the corresponding class information, and the [class information is stored in the method area]), and the memory allocated in the heap, there is a virtual machine's automatic garbage collector management, stack memory is only visible to its thread.

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

 

Error

IfStack memoryNo available space storage method calls and local variables, JVM will throw java. lang. StackOverFlowError.
If yesHeap memoryNo available storage space for the generated objects, JVM will throw java. lang. OutOfMemoryError.

 

Space size

The stack memory is much smaller than the heap memory. If you use recursion, your stack will soon be full. StackOverFlowError may occur if recursion does not jump out in time.
You can use the-Xss option to set the stack memory size. -The Xms option can be used to set the size at the beginning of the heap, and the-Xmx option can be used to set the maximum value of the heap.

 

Method Area:

It is also called a static zone, which is shared by all threads like a heap. It is used to store data such as class information, constants, static variables, and compiled code that has been loaded by virtual machines.

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.