Garbage Collection

Updated May 4, 2026

Short answer

Automatic memory management.

Deep explanation

Primarily uses reference counting. If count is zero, memory is freed. A cyclic collector handles reference cycles.

Real-world example

Cleaning up large temporary objects in a long-running data pipeline.

Common mistakes

  • Creating circular references (A points to B, B points to A) which can delay cleanup.

Follow-up questions

  • What is the 'gc' module?

More Python interview questions

View all →