The algorithm is divided into two stages: marking and clearing:
Disadvantages:

Runtime Stack runtime virtual machine stack-using root search algorithm
Stack as root
Through the root search algorithm, it is calculated that D, G, F, J, M have no references, so they are recycled
The marking process is still the same, but the next step is not to directly clean up, but to move all living objects to one end, and then directly clean up the memory beyond the boundary of this end.

Divide the available memory into two blocks, and only use one of them each time. When half of the memory is used up, only the surviving objects are copied to another block, and then the original entire memory space is cleared at once.
In this way, each time the memory is recycled for the entire half-area, memory allocation does not need to consider the complicated situation such as memory fragmentation, as long as the top pointer of the heap is moved, the memory is allocated in order, which is simple and efficient.
Today's commercial virtual machines use this replication algorithm to recycle the new generation (newly-created objects are in the new generation).
If you don’t want to waste 50% of the space, you need to allocate additional space to guarantee that all objects in the half-area memory are 100% alive, so you can’t directly choose this algorithm in the old generation.


Four GC algorithms Overview Reference counting Copying algorithm (Copying) Mark-Sweep Mark compression algorithm (Mark-Compact) to sum up Overview When JVM is performing GC,The above three memory area...
I. Introduction Recently, I have a little work in the background. I have been reviewing the JVM stuff and it is still very interesting. Second, the algorithm Graphic + point summary Reference count pr...
Reference counting(Rarely used): Use a counter to count the number of times the objects in the heap are referenced, and clear the objects that are not referenced 2.Replication algorithm: Every time th...
This is a sharing in November. Taking the opportunity of sharing within the group, I re-organized some basic concepts and learning materials of JVM. In this PPT, the part about G1 is relatively rough....
JVM garbage collection overview The garbage collection mechanism is Java's signature ability, which greatly improves development efficiency. Nowadays, garbage collection is almost called the standard ...
Four major algorithms of GC 1. Copy algorithm Young generationMinor GC is used in, this GC algorithm uses the copy algorithm (Copying) JVM divides the young generation into three parts: 1 Eden area ...
E.g:java -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:gc.log Hello The printed log is as follows GCView It is a log query tool that can view the overall GC performance in a graphical interface. ...
Article Directory 0. How to judge whether an object is alive in Java? 0.1 Reference counting algorithm 0.2 Root search method 1. Copying algorithm (Copying): suitable for the new generation 1.1 Princi...
Foreword: As an intern, when this sentence appears on your resume: "Familiar with GC's commonly used algorithms, familiar with common garbage collectors, and practical experience with JVM tuning&...
This article will focus on the graphical description of the reference counter, the copy algorithm, the mark cleaning method, the implementation principle of marking compression method, and process Ref...