Jvm memory,

Source: Internet
Author: User

Jvm memory,

 

I saw a summary from Niuke. I felt that it was well written. record it.

Most JVMs divide the memory Area into Method Area (Non-Heap), Heap, Program Counter Register, and VM Stack (Virtual Machine Stack, also translated into JAVA Method Stack), Native Method Stack (local Method Stack), where Method Area and Heap are shared by threads, VM Stack, native Method Stack and Program Counter Register are not shared by threads. Why is it divided into thread sharing and non-thread sharing? Continue.

First, we are familiar with the working process of a General Java program. A Java source program file will be compiled into a bytecode file (with the class Extension). Every java program needs to run on its own JVM, and then inform the JVM program running portal, it is then loaded and run by JVM through the bytecode interpreter. After the program starts running, how does it involve various memory regions?

In summary, the Method Area and Heap are allocated during the initial running of the JVM. Every time the JVM encounters a thread, assign a Program Counter Register (Program Counter), VM Stack, and Native Method Stack. When the thread ends, the memory space occupied by the local method stack and program counters will also be released. This is also the reason why I divide the memory area into thread sharing and non-thread sharing. The life cycle of the three regions that are not thread sharing is the same as that of the thread, the thread-shared area has the same lifecycle as the JAVA program running, so this is also the place where the system garbage collection occurs only in the thread-shared area (in fact, most virtual machines know that it occurs on Heap).

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.