---
title: "Explain Python’s garbage collection mechanism."  
description: "Explain Python’s garbage collection mechanism."  
author: "Anubhav Sharma"  
published: 2025-11-06  
updated: 2025-11-06  
canonical: https://www.mindstick.com/interview/34404/explain-python-s-garbage-collection-mechanism  
category: "python"  
tags: ["python-3.4", "Python 3", "Python Optimization"]  
reading_time: 1 minute  

---

# Explain Python’s garbage collection mechanism.

Python uses **reference counting** and **a cyclic garbage collector**.

- When an object’s reference count becomes zero, it’s automatically destroyed.
- The **gc module** handles circular references.

```python
import gc
gc.collect()  # manually trigger garbage collection
```

## Answers

### Answer by Anubhav Sharma

Python uses **reference counting** and **a cyclic garbage collector**.

- When an object’s reference count becomes zero, it’s automatically destroyed.
- The **gc module** handles circular references.

```python
import gc
gc.collect()  # manually trigger garbage collection
```


---

Original Source: https://www.mindstick.com/interview/34404/explain-python-s-garbage-collection-mechanism

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
