JVM Memory Miscellaneous 1

Source: Internet
Author: User

  

Most JVMs divide the memory area into method Area (non-heap) , Heap(heap) , program Counter Register (procedure counter) , VMStack (virtual machine stack, also translated into Java method stack), Native method Stack(local stack).

  Method area and Heap are thread-shared .

  VM stack,native Method Stack and program Counter Register are non-thread-shared .

Why is it divided into thread sharing and non-thread sharing? Please continue looking down.

First, we are familiar with the working process of a generic Java program. A Java source program file will be compiled into a bytecode file (with class extension), each Java program needs to run on its own JVM, and then inform the JVM program run the portal, and then by the JVM through the bytecode interpreter load run. So how does the program get involved in each memory area after it starts running?

In a nutshell, when the JVM is initially running, it allocates the method area and heap (heap), and each time the JVM encounters a thread, it assigns it a program Counter Register (Application counter), VM stack (virtual machine stack), and N Ative method Stack (local stack), when the thread terminates, the memory space occupied by the three (virtual machine stack, local method stack, and program counter) is also freed. This is why I divide the memory area into thread sharing and non-thread sharing, and the three areas of non-thread sharing have the same life cycle as the owning thread, while the areas shared by the threads are the same as the Java program's life cycle. So this is where the system garbage collection takes place only in the area of the thread share (which is actually known to the heap on most virtual machines).

JVM Memory Miscellaneous 1

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.