I spent a good part of the day today troubleshooting memory problems on some postfix mail servers. Each smtpd process was using over 11 MB of Ram which seems really high. Each concurrent SMTP session has its own smtpd process, and with over 150 concurrent connections, that was using well over 1.5 GB of Ram.
[root@mail ~]# ps aux|grep -i smtpd |head -n1 postfix 3978 0.0 0.5 16096 11208 ? S 12:29 0:00 smtpd -n smtp -t inet -u
After some trial and error of temporarily disabling stuff in the main.cf file, I narrowed the memory usage to a regexp table in a transport map:
transport_maps = regexp:/etc/postfix/transport.regexp
The transport.regexp file had about 1400 lines in it to match various possible address variations for a stupid mailing list application. Each mailing list has 21 different possible commands (addresses). By combining those 21 different commands into a single regex, I was able to cut those 1400 lines down to about 70. Now the smtpd processes use just under 5mb each:
[root@mail ~]# ps aux|grep -i smtpd |head -n1 postfix 7634 0.0 0.2 9916 4996 ? S 13:31 0:00 smtpd -n smtp -t inet -u
So, by my math, a savings of about 6,000 kb of memory by removing 1300 lines from the regexp file means that each regexp used about 4.5 kb of memory. Overall, with 150+ simultaneous smtpd processes, that resulted in several hundred megs of memory saved on each mail server.