Garbage collectors have a lot of variety, depending on requirements (memory overhead, latency, data location, ...). Some of my answers may not apply to some complex collectors.
-, needToGc: , malloc .
, , , , , . , , . :
, , . , , .
mark-and-sweep. , 0. , : 1, ; 0, 1 , . . , : - 0, ; reset 0.
"--sweep", .
. wikipedia .