[Pymilter] no memory release when assigning chunks to self.fp in milter-template.py
Stuart D. Gathman
stuart at gathman.org
Tue Feb 4 17:38:02 EST 2020
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.
--
Stuart D. Gathman <stuart at gathman.org>
"Confutatis maledictis, flammis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.
More information about the Pymilter
mailing list