jvm

The JVM execution engine executes the bytecode files of each class that have been loaded by the JVM class loader, and the Java compiler compiles the Java source code into.class bytecode files

During the execution of a Java program, the JVM divides the memory it manages into different data regions

Java memory: a portion of the space allocated by the JVM to manage Data and related information during the Runtime of a program.

Runtime data area: Two parts, thread private and shared data area. Thread private includes local method area, virtual machine stack, program counter; The shared data area contains the Java heap, method area (with constant pool)

Program counter: Records the address of the virtual machine bytecode file being executed

Virtual machine stack: the memory area where methods are executed. When methods are executed, stack frames are created in the stack. The life cycle of methods is the same as that of threads

Local method area: Memory space provided for Native methods used by virtual machines

Java heap: The largest chunk of memory managed by the JVM, the primary area managed by the GC. In main memory, the objects themselves and arrays are stored as the JVM is created

Method area: stores data such as class information, constants, static variables, and code compiled by the compiler that has been loaded by the VIRTUAL machine

Constant pool: Holds the various literal and symbolic references that the compiler lives in, part of the method area

Memory model: JMM, Java Memory Model. Defines how the JVM works in the computer’s memory RAM, and Java interthread communication is controlled by the JMM to determine when a write to a shared variable by one thread is visible to another

Abstract Perspective: THE JMM defines an abstract relationship between threads and main memory, where shared variables between threads are stored in main memory (heap memory) and thread private local memory holds copies of read and write shared variables

Communication mechanisms between threads: shared memory and messaging

The difference between the memory model and the runtime data area: the JVM runtime data area defines the management division of the JVM runtime storage, while the memory model defines the access rules for shared variables in the program, ensuring atomic ordering visibility, thread collaboration and data security

JVM reclamation strategy: The heap space is divided into old generation and young generation in the MEMORY space managed by the JVM. Objects that die shortly after creation are in the young generation, and instance objects with a long lifetime are in the old generation

Does the JVM determine whether an object should be reclaimed? A directed graph was established, through GC roots to traverse down, object unreachable state, mark, and later GC recovery