In-depth analysis of the use of Java memory areas _java

Source: Internet
Author: User

Java Memory Partitioning:

In Java memory allocation, Java divides memory into: Method area, heap, virtual machine stack, local method stack, program counter. Where the method area and heap are shared for all threads, and the virtual machine stack and the local method stack have program counters for thread isolation. Each zone has its own creation and destruction time.

Program Counter:

Action is the line number indicator of the byte that the current thread executes. Java multithreading is achieved by rotating threads and allocating processor execution time. Therefore, each thread needs a separate program counter in order to be able to revert to the correct position after switching.

Java Virtual Machine Stack:

Each place is executed at the same time to create a stack frame for the storage of local variables table, operand stack, dynamic link, method of export information. The virtual memory stack is what we often talk about "stacks." Where the memory required for a local variable table is allocated at compile time.

Local method Stack:

Similar to the virtual machine stack, the difference is that the virtual machine stack performs Java method services for the virtual machine, while the local method stack uses the native method service for the virtual machine.

Java Heap:

is shared by all programs and is created when the virtual machine is started. This memory area function is to hold an object instance. According to the Java virtual machine, the Java heap can be in a physically discontinuous memory space, as long as it is logically contiguous.

Method Area:

The same as the heap, shared among the threads. The role is to store data such as class information that has been loaded by the virtual machine, constants, static variables, just-in-time compiler compiled code, and so on.

Run a frequent pool:

is part of the method area. The effect is to store the various literal and symbolic references generated by the compilation period.

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.