`gc.collect()`'s Hidden Insight: Uncollectable Objects

The `gc.collect()` function returns the number of unreachable objects found, which includes both successfully freed objects and those that could not be freed (e.g., due to reference cycles with `__del__` methods or remaining strong references), providing a crucial signal for identifying potential memory leaks or unhandled references, often visible in the `gc.garbage` list [1, 3, 8, 12].

Sources

Open the full topic