One of the key points of the JVM virtual machine memory model

Hostpot virtual machine runtime data area memory model

JVM virtual machine memory distribution model

  • The white part is the shared memory of all threads when the JVM is running
  • The blue part is the thread exclusive memory

A shared memory

1 Method area characteristics

  • Used to store class information, constants, and static variables loaded by the virtual machine
  • The jvm specification describes it as a logical part of the heap, but it is different. Alias ​​No-Heap non-heap
  • GC seldom recycles this part of memory because it has little effect
  • The main GC recovery target is this part of the runtime constant pool (String.intern and other methods will generate runtime constants) and the type is written in

2 Heap characteristics

  • Store object instances, almost all object memory is allocated here
    (with the development of techniques such as escape analysis scalar replacement on the stack , not all object instances are allocated on the heap)
  • GC's main recycling goal is divided into the new generation and the old generation in order to facilitate the storage of the heap memory
  • The heaped memory can be configured to be expandable and controlled by -xmx -xms

Two-thread private memory area

1 Program counter

  • A small area guides the thread code execution order

2 virtual machine stack

  • Life cycle is the same as thread
  • Store local variable table and other information
  • Local variable table : stores various data types known at compile time, and object references

3 Local method stack

  • Different from the virtual machine stack serving native methods

Three other memory areas

  1. Direct memory: use native method native to directly allocate off-heap memory
Published 17 original articles · won 24 · views 280,000 +

Guess you like

Origin blog.csdn.net/qq_22956867/article/details/78041877