The `gc.set_debug()` function with flags like `gc.DEBUG_STATS` or `gc.DEBUG_UNCOLLECTABLE` provides detailed printouts of GC runs, including collection counts, durations, and objects that couldn't be collected due to remaining references.
Open the full topic