In the various parts of the Java Memory Runtime area: Program counter, virtual machine stack, local method stack with line generates and off,
For the heap and method extents in Java, which objects will be created only while the program is running, this portion of memory allocation and recycling is dynamic, and the garbage collector focuses on this part of memory.
What memory needs to be recycled?
When do I recycle?
How to recycle?
The garbage collector needs to determine which objects are dead before the heap is recycled (objects that can no longer be used by any means)
The general approach is to add a reference counter to the object, that is, the reference counting algorithm to manage memory, but the JVM does not, because there is no way to resolve the problem of circular references between objects.
1: Accessibility analysis
Garbage collector and memory allocation policies