[Pymilter] no memory release when assigning chunks to self.fp in milter-template.py
joao reis
joao at 7lan.net
Tue Feb 4 17:51:30 EST 2020
Sorry, but this is just the example provided in the pymilter
documentation, and as I said, the same problem occurs when assigning the
value of "chunks" in a variable or even in a file, nothing related to
BytesIO or StringIO. I made sure to keep the example provided in the
pymilter documentation (as you can see from the link pasted
https://github.com/joaoreis81/milter-template/blob/master/milter-template.py)
that there is no change that could affect assignments to self.fp. I'm
starting to think that there really isn't going to be a solution to this.
On 2/4/20 7:38 PM, Stuart D. Gathman wrote:
> On Tue, 4 Feb 2020, joao reis wrote:
>
>> With "del self.fp" it is consuming 244.6 MiB in just one hour.
>
> That proves pretty conclusively that the problem is not with postfix or
> pymilter. Either BytesIO/StringIO are badly broken (unlikely, we can
> make a non-milter test), or you have "leaked" a reference to self.fp
> (or self.fp.getvalue()) somewhere where it is being colllected globally.
>
> Although, you are doing it wrong:
>
>> if self.fp:
>> self.fp.close()
>> self.fp = None
>> del self.fp
>> return Milter.CONTINUE
>
> You need to delete *before* setting to None, otherwise it is a noop.
> But even just setting it to None will immediately reclaim the memory
> in C-Python when it is the last reference. So apparently, it
> is not the last reference.
>
More information about the Pymilter
mailing list