Why I fail so bad to check for memory leak with this code?

Barry barry at barrys-emacs.org
Fri Jul 22 03:00:01 EDT 2022





> On 21 Jul 2022, at 21:54, Marco Sulla <Marco.Sulla.Python at gmail.com> wrote:
> On Thu, 21 Jul 2022 at 22:28, MRAB <python at mrabarnett.plus.com> wrote:
>> 
>> It's something to do with pickling iterators because it still occurs
>> when I reduce func_76 to:
>> 
>> @trace
>> def func_76():
>>     pickle.dumps(iter([]))
> 
> It's too strange. I found a bunch of true memory leaks with this
> decorator. It seems to be reliable. It's correct with pickle and with
> iter, but not when pickling iters.

With code as complex as python’s there will be memory allocations that occur that will not be directly related to the python code you test.

To put it another way there is noise in your memory allocation signal.

Usually the signal of a memory leak is very clear, as you noticed.

For rare leaks I would use a tool like valgrind.

Barry

> -- 
> https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list