On Wed, May 13, 2020 at 9:17 AM Ammar Askar <ammar@ammaraskar.com> wrote:
 > Py_DECREF calls in the C code

I think this part specifically is already covered through refleak
checks: https://github.com/python/cpython/blob/master/Lib/test/libregrtest/refleak.py

Since it can involve the repetition of tests many times, these aren't
run on the CI though, they do get run on the refleak buildbots so
issues get caught eventually:
https://buildbot.python.org/all/#/builders?tags=%2Brefleak

But again this is for PyObjects only. Were you able to find any memory
leaks with your proof-of-concept? I don't think there's a lot of
chances of someone missing a PyMem_Free call and there's not a lot of
other manual memory management but I could be wrong. Anything found
there could help motivate adding this a bit more.

Yeah, I agree it depends on how many PyMem_* occurrences are there, and it probably makes more sense to cover those ones only. Under Modules/* I found:

- 24 occurrences for PyMem_RawMalloc
- 2 for PyMem_RawCalloc
- 106 for PyMem_Malloc
- 12 for PyMem_Calloc
- 39 for PyMem_New
- 5 for " = malloc("

I spent an hour covering around 20 of those and didn't find any leak. It's a boring work. I will try to work on it over the next few weeks.