Go deep into the java-java memory area

Source: Internet
Author: User

Java memory Division:

In Java memory allocation, Java divides the memory into: Method Area, heap, virtual machine stack, local method stack,ProgramCounter. The method zone and heap share all threads, while the Virtual Machine stack and the local method Stack also have program counters that isolate threads. Each region has its own creation and destruction time.

Program counter:

It is the row number indicator of the byte executed by the current thread. Java multithreading is implemented by switching threads in turn and allocating the processor execution time. Therefore, in order for each thread to be able to return to the correct position after switching, each thread needs an independent program counter.

Java Virtual Machine Stack:

Each stack frame is created during execution to store information such as the local variable table, operand stack, dynamic link, and method exit. The Virtual Memory stack is the "stack" we often talk about ". The memory required for the local variable table is allocated during the compilation period.

Local method Stack:

Similar to the Virtual Machine stack, the difference is that the virtual machine stack executes Java method services for the virtual machine, while the local method stack uses native method services for the virtual machine.

Java heap:

Shared by all programs and created when the VM is started. This memory area is used to store object instances. According to Java Virtual Machine regulations, Java heap can be physically discontinuous memory space, as long as the logic is continuous.

Method Area:

Same as the heap, it is shared among various threads. The function is to store information about classes loaded by virtual machines, constants, static variables, and compiled by the real-time compiler.CodeAnd other data.

Runtime frequent volume pool:

Is part of the method area. The function is to store various literal and symbolic references generated during 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.