Runtime data area overview and threads

Runtime data area overview and threads

Data area diagram at runtime:

Insert picture description here

Diagram of the role played by the runtime data area in the entire jvm:

Insert picture description here

Memory is a very important system resource. It is an intermediate warehouse and bridge between hard disk and CPU, and carries the real-time operation of operating systems and applications. The memory layout of the JVM stipulates the strategy of memory application, allocation, and management during the operation of Java, which ensures the efficient and stable operation of the JVM. Different JVMs have some differences in memory division and management mechanisms. Combined with the JVM virtual machine specification, let's discuss the classic JVM memory layout.

Insert picture description here

The Java virtual machine defines the runtime data area that will be used during the running of thousands of programs, some of which will be created when the virtual machine is started, and destroyed when the virtual machine exits. Others have a one-to-one correspondence with threads, and these data areas corresponding to threads will be created and destroyed as threads start and end.

The gray ones are private to a single thread, and the red ones are shared by multiple threads.

  • Each thread: independently includes the program counter, stack, and local stack.
  • Sharing between threads: heap, off-heap memory (permanent generation or meta space, code cache)

Insert picture description here

The method area and heap are shared between threads, as shown in the red part of the following figure:

Insert picture description here

###About sharing between threads:

There is only one Runtime instance per JVM. It is the runtime environment, which is equivalent to the frame in the middle of the memory structure, the runtime environment.

Guess you like

Origin blog.csdn.net/qq_37924905/article/details/108587835