[Mimedefang] Mimedefang with postfix. Process memory usage over time.

Robert Theisen trobert at redhat.com
Fri Nov 10 10:33:10 EST 2017

We have an environment with postfix-2.10.1-6.el7.x86_64 and
mimedefang-2.78-6.el7.x86_64 .  Postfix is configured to interact with
mimedefang via smtpd_milters =

[root at ext-mx02 ~]# uname -a
Linux ext-mx02 3.10.0-514.21.2.el7.x86_64 #1 SMP Sun May 28 17:08:21
EDT 2017 x86_64 x86_64 x86_64 GNU/Linux

[root at ext-mx02 ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:            15G         10G        2.5G        692M        2.6G        4.0G
Swap:          8.1G        5.8G        2.3G

The mimedefang process looks like this after running for approximately 3 weeks

defang   26810  0.3 42.8 12680732 6961512 ?    Sl   Oct17 109:15
/usr/bin/mimedefang -P /var/spool/MIMEDefang/mimedefang.pid -m
/var/spool/MIMEDefang/mimedefang-multiplexor.sock -y -R -1 -U defang
-T -r -H -s -t -G -q -p /var/spool/MIMEDefang/mimedefang.sock

12.1 GB VIRT
6.6 GB RES

I checked the smap data for that mimedefang process and selected one
of the many 64MB blocks that was currently in swap.

7f895c000000-7f895fffc000 rw-p 00000000 00:00 0
Size:              65520 kB
Rss:               65520 kB
Pss:               65520 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:     65520 kB
Referenced:        37632 kB
Anonymous:         65520 kB
AnonHugePages:         0 kB
Swap:                  0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Locked:                0 kB
VmFlags: rd wr mr mw me nr sd

I did a memory dump of that block and ran strings against it and I got
a quarter of a million lines that look like this ...

_ {auth_authen} {auth_author} {auth_ssf} {auth_type} {cert_issuer}
{cert_subject} {cipher} {cipher_bits} {daemon_name} {daemon_port} i
{if_addr} {if_name} j {mail_addr} {mail_host} {mail_mailer}
{tls_version} {verify} {rcpt_addr} {rcpt_host} {rcpt_mailer}

That seems to correspond to this code snippet in mimedefang.c line 161
(in version 2.78) ...

/* Standard Sendmail macros */
/* We can't make it char const * because libmilter
   is not const-correct. */
static char *StandardSendmailMacros[] = {
    "_", "auth_authen", "auth_author", "auth_ssf", "auth_type",
    "cert_issuer", "cert_subject", "cipher", "cipher_bits", "daemon_name",
    "i", "if_addr", "if_name", "j", "mail_addr", "mail_host", "mail_mailer",
    "tls_version", "verify", "rcpt_addr", "rcpt_host", "rcpt_mailer",
    /* End of macros MUST be marked with NULL! */

and that macro gets copied to dbuf at line  952

    /* Write the standard macros */
    macro = StandardSendmailMacros;
    while (*macro) {
        append_macro_value(&dbuf, ctx, *macro);

Is it possible that that dbuf is not getting freed properly on down the line?

More information about the MIMEDefang mailing list