Garbage Collection(GC) explained

作者:半瓶墨水   链接:

(*lonely* : no one refer to him/them)

1. remove lonely guy
— naive reference counting
— BAD: couples(cycle references)

2. remove lonely *couples* (cycle references)
— mark and sweep
— BAD: during GC, freeze the App, like early Java

3. remove lonely guys *on-the-fly*
— Tri-color marking

4. remove *new* lonely guys more often
— as they are not referred as much as old guys
— “generations”

5. after remove, rearrange the room
— move/no move

…more details in the link, not interesting though…