On Wed, 2020-05-13 at 13:14 +0100, Pablo Galindo Salgado wrote:
> > But again this is for PyObjects only.
> 
> Not really, we check also memory blocks:
> 
> https://github.com/python/cpython/blob/master/Lib/test/libregrtest/refleak.py#L72
> 
> as long as you don't directly call malloc and use one of the Python
> specific APIs like PyMem_Malloc
> then the reflect code should catch that.

Maybe worth briefly mentioning in this discussion that pytest-leaks
exists:

https://github.com/abalkin/pytest-leaks

which serves much the same purpose as refleak.py for pytest users. (I
run it semi-regularly on NumPy and it helped me get the tests de-facto
free of leaks.) I have used valgrind for similar purpose, but
refleaks/pytest-leaks is better for leaks.

Cheers,

Sebastian


> 
> On Wed, 13 May 2020 at 12:29, Giampaolo Rodola' <g.rod...@gmail.com>
> wrote:
> 
> > On Wed, May 13, 2020 at 9:17 AM Ammar Askar <am...@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.
> > 
> > _______________________________________________
> > Python-Dev mailing list -- python-dev@python.org
> > To unsubscribe send an email to python-dev-le...@python.org
> > https://mail.python.org/mailman3/lists/python-dev.python.org/
> > Message archived at
> > https://mail.python.org/archives/list/python-dev@python.org/message/C7ZZRDPGIUS7Q6Q4AS4YFPD2OOF56JBO/
> > Code of Conduct: http://python.org/psf/codeofconduct/
> > 
> 
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-dev@python.org/message/YNBGAWNCCHF3XK3MBHJWZI4NKTNEPKV6/
> Code of Conduct: http://python.org/psf/codeofconduct/

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/TOPMBKEH7VVKMDZM7QE6XQ6GUU64WKCW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to