PythonExtensionPatterns icon indicating copy to clipboard operation
PythonExtensionPatterns copied to clipboard

COUNT_ALLOCS was removed in Python3.9

Open ngoldbaum opened this issue 1 year ago • 0 comments

I spent a bit of time following the (normally excellent) advice in this tutorial to try a COUNT_ALLOCS build while debugging a reference leak and found that it did nothing. It turns out CPython removed the functionality in Python 3.9. See https://github.com/python/cpython/pull/18259.

Unfortunately there isn't a replacement.

Should all the text referencing COUNT_ALLOCS just be removed? It would avoid wasting the time of future people who would like to debug reference issues.

I ended up fixing the issue I had by setting a breakpoint on the variable in the debug python build tracking the total number of allocations and then over the course of a python for loop that leaked memory every loop, simply printed out the objects getting increfd and decrefd and found the place where an object was getting an extra incref. Maybe I could describe this debugging process?

ngoldbaum avatar Mar 03 '23 18:03 ngoldbaum