GC Types

Reference counting

  • COM for example had AddRef and Release cals for objects

  • When count hits zero => object can be freed

  • Problems with circular references

Mark and sweep

  • Mark phase - identify objects that are still in use

  • Sweep phase - remove unused objects

  • Compact phase - compact the memory

We follow references from root set. If two objects are referencing each other, but non of them is referenced by root set => these objects will not be marked as actually used (this is how cycle problem is solved).

Copying

Uses different spaces to manage memory. It also has Mark and Sweep phases.

Generational

Maintain different generations for memory. Long living objects promoted to a different generation.

Last updated