Memory Management

发布时间 2023-06-13 16:42:16作者: shendawei

refcount

  • (reference count), a mechanism used by the Python interpreter to manage the memory of objects.
  • When the reference count of an object reaches 0, the Python interpreter automatically deallocates the memory used by the object and frees it for reuse. This process is called garbage collection.

cyclic garbage collection

  • A more complex garbage collection algorithm used to handle circular references
  • It works by periodically scanning the heap for cyclic references and deallocating the memory used by any unreachable objects found in the cycle.
  • This process is triggered automatically when the number of allocated objects reaches a certain threshold, or can be triggered manually using the gc.collect() function.