1. What is garbage
No references to an object or plurality of objects (circular references)
2. How to locate trash
Reference counting (not solve circular references)
Root up algorithm (root object can not be found by the objects are garbage)
The root object: thread stack variables, static variables into the Class of constant pool reference variables and pointers to the JNI
3. Common garbage collection algorithm
Mark-Sweep (flag clearing): positions discontinuously, fragmentation
Copying (copy): free of debris, waste of space
Mark-Compact (marked compression): no fragmentation, low efficiency
4.JVM generational memory model (for generational garbage collection algorithm)
1. The model used by the garbage collector portion
2. Cenozoic + + years old and permanent generations (1.7) / metadata area Metaspace (1.8)
Permanent generation difference metadata area:
Class objects are loaded
You must specify the size of the permanent generation of limitations. Metadata area may be provided, may not be provided, without limit (limited by the physical memory)
String constants in the 1.7 is stored in the permanent generation, 1.8 on the heap
3. The new generation region = eden survivor regions +2
After 1.YGC recovery, most of the objects will be recovered alive Copying using the algorithm proceeds survivor zone (s0)
2. YGC again, alive object eden + s0 -> enter s1
3. YGC again, alive object eden + s1 -> enter s0
4. old enough -> enter the old year
5.s area fit -> years old
4 years old
Old and full of years will trigger a FGC (Full GC)
5.GC Tuning (generational algorithm)
1. minimize FGC
MinorGC = CVL
MajorGC = FGC
5. Common garbage collector
1.Serial: Serial recovered, single-threaded (the new generation)
2.Parallel Scavenge: parallel recovery, multiple threads (the new generation)
3.ParNew: parallel with the recovery of the CMS (the new generation)
4.Serial Old (years old)
5.Parallel Old (years old)
6.CMS (ConcurrentMarkSweep) (years old)
JDK1.8 default garbage collector: Parallel Scavenge + Parallel Old