Java memory model

Source: Internet
Author: User

The Java Virtual machine executes the Java program by dividing the memory it manages into a number of different data regions, called the runtime data areas.

Program counter

A program counter is a small amount of memory space that can be thought of as the line number indicator of the byte code executed by the current thread. Each thread needs to have a separate program counter, and the counters between the threads do not affect each other and are stored independently.

Java Virtual Machine stack

The virtual machine stack describes the memory model that the Java method executes: Each method creates a stack frame to store information such as local variable tables, operand stacks, dynamic links, method exits, and so on. Each method from the call until the completion of the process, corresponding to a stack frame in the virtual machine stack into the stack of the process.

Local method Stack

The local method stack is similar to the virtual machine stack, and the local method stack is the native method service that is used for the virtual machine.

Java heap

The Java heap is a piece of memory that is shared by all threads and created when the virtual machine is started. The only purpose of this memory area is to hold object instances where almost all object instances are allocated memory.

Method area

The method area, like the Java heap, is an area of memory shared by each thread that stores data such as class information, constants, static variables, and code compiled by the immediate compiler that have been loaded by the virtual machine.

Reference
1, Zhou Zhiming, in-depth understanding of Java Virtual machines: JVM advanced features and best practices, mechanical industry Press

Java memory model

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.