[Pymilter] no memory release when assigning chunks to self.fp in milter-template.py

Stuart D. Gathman stuart at gathman.org
Tue Feb 4 18:24:52 EST 2020


On Tue, 4 Feb 2020, joao reis wrote:

> 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"

Since the memory continues to grow even when you explicitly delete your
variable, whatever you are measuring has nothing to do with the milter
framework or postfix not automatically collecting it.  You could test
your milter using one of the two test frameworks provided in pymilter 
and skip the inconvenience of running it with postfix.

A much more complex milter stays at 24728 K indefinitely:
 			  VIRT    RES    SHR
20918 mail      20   0  579844  24728   6164 S   0.0  2.4   0:17.19 bms.py

It is normal for C-python to allocate more memory initially, until it has
a stable pool to recycle.  You may have mentioned it initially, but
how much memory are we talking about?  If you need minimal memory
consumption, python may not be the best choice.  Note that C-python
is NOT going to return memory to the OS just because you deleted some
big strings.  (Especially since it rightfully suspects you are going to
allocate some big strings again with the next email message.)

What are you looking at to measure the memory use?

You do not have to run your milter as a daemon.  It works perfectly
well in the foreground, so there should be nothing preventing you from
using the memory profiling tool you mentioned.  Just run your milter
from the profiling tool.

-- 
 	      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