How does the garbage collector determine if an object is garbage?

How does the garbage collector determine if an object is garbage? Does this relate to the stack for checking references to space allocated on the heap?

+3
source share
3 answers

It uses a mark and a sweep algorithm . Simplified version: begins with a review of all the objects to be collected. Then it scans the roots for objects. Any root object is then marked as being used. After that, all other objects are considered garbage. There's a great description of the details in the CLR via C # Jeffrey Richter.

+4
source

. , .

, GC . , .

, GC , GC. , ( ). , .

, , GC .

+3

: Java: .

0

Source: https://habr.com/ru/post/1738001/


All Articles