Heap Partitioning: All new objects will be stored in the heap
> New Generation (Young Generation): Storage of short life-cycle objects, specifically divided into Eden and survivor two districts, of which survivor is divided into from space and to space; > Old Generation: Storing long-life objects > Durable generation (permenent Generation): For storing class bytecode, etc. The GC algorithm used by the JVM is: Generational collection > Frequent collection of new Generation > Less collection of old generation > Basic non-collection of persistent generations The GC mechanism of the JVM is divided into: Minor GC and full GC > Minor GC: The normal GC, which collects all the objects in the Cenozoic, copies all the living objects in Eden into the survivor, and if the survivor doesn't fit, survivor alive. Objects into the old generation > full GC: The new generation and the old generation are collected, and the algorithm is less efficient than the GC. When you explicitly call System.GC (), the full GC is performed. > Trigger conditions: Eden is full to trigger minor GC; When new objects enter the old generation, the old generation space is insufficient JVM cleanup algorithm: > Reference counting Method (early JVM): The JVM counts the number of references to an object, creates it, adds a reference out of scope, and, when the count is 0 o'clock, collects > object reference traversal: The JVM iterates through all the root objects, determines the reachable objects recursively based on the object graph, if An object instance can arrive from the root object, it is labeled as a tagged object, and during the collection phase, simply scan the stack and delete all unmarked objects. Compression is generally done later to make room for new objects. > Copy Cleanup method How the JVM cleans up an object: > New generation: Using the Copy cleanup method, copy the reachable objects to an unused area, such as survivor, and then clear all objects in Eden > Legacy generation: Use tag cleanup and compression, and the content is traversed by the object reference. > mechanism: Serial and parallel, string exercise for single-threaded, single-CPU, and exercise for multi-threaded, multi-core CPUs. Tuning: > Use tuning: Assign null to unused objects as early as possible, rather than wait until the exit lifecycle is automatically assigned, less finalize () will increase GC workload, and when the program waits, manually execute System.GC (); > Virtual machine optimization option: Online query
JVM GC Notes