# amavisd-new is seriously hogging memory

## ewie

Hi all,

Since amavis old-style is removed from portage, i upgraded to amavisd-new. Now amavisd is seriously hogging my memory.

```
ster / # ps -eo pmem,args,user | sort -nr | head

19.8 amavisd (ch1-24079-01)      amavis

19.2 amavisd (ch1-avail)         amavis

19.0 amavisd (master)            amavis

 6.0 /usr/sbin/apache2 -D PHP4 - apache

 5.7 /usr/sbin/apache2 -D PHP4 - apache

 4.8 /usr/sbin/apache2 -D PHP4 - root

 4.0 /usr/sbin/apache2 -D PHP4 - apache

 1.6 /usr/sbin/mysqld --basedir= mysql

 1.4 /usr/sbin/named -u named -n named

 1.1 sshd: root@pts/1            root

 1.1 sshd: root@notty            root

```

My box is a PIII 500 with 192 MB of RAM. I don't have a lot of mail traffic (less than 100 a day) but i want to use amavis and spamassassin. Is there a way to tune amavisd-new to use less memory? Compile perl with ithreads or something? An other way to use amavisd in stead of deamonize it?

amavis runs with 2 children, uses f-prot as virusscanner and spamassassin as spam assassin.

Thanks for any suggestions.

----------

## Janne Pikkarainen

I've been trying to track down similar issue, although my setup has amavisd-new + SpamAssassin 3.x + pyzor + razor + dcc. In my case the situation is pretty bad, too, since even a freshly started amavisd-new process takes quite a lot of memory:

```
amavis   12513  0.0  1.3  64128 35932 ?        S    16:36   0:00 amavisd (virgin child)
```

According to Google it seems that SA 3.x is a memory hog. I don't know (yet) what causes it to eat so much memory, but I suspect there are several large rulesets lurking around. Whether it's possible to disable those without sacrificing too much spam blocking effiency, go figure.

----------

## ewie

 *Janne Pikkarainen wrote:*   

> According to Google it seems that SA 3.x is a memory hog. I don't know (yet) what causes it to eat so much memory, but I suspect there are several large rulesets lurking around.

 

Hmm, when i disable spam filtering in amavisd.conf, it's a lot better, but still quite nasty.

```
@bypass_spam_checks_maps  = (1);  # uncomment to DISABLE anti-spam code
```

```
ster ~ # ps -eo pmem,args,user | sort -nr | head

10.8 amavisd (virgin child)      amavis

10.8 amavisd (virgin child)      amavis

10.8 amavisd (master)            amavis

 6.1 /usr/sbin/apache2 -D PHP4 - apache

 6.0 /usr/sbin/apache2 -D PHP4 - apache

 4.8 /usr/sbin/apache2 -D PHP4 - root

 4.0 /usr/sbin/apache2 -D PHP4 - apache

 2.9 /usr/bin/perl -w /usr/bin/m root

 1.9 /usr/bin/perl -w /usr/local root

 1.6 /usr/sbin/mysqld --basedir= mysql

```

----------

## Janne Pikkarainen

There is also a program called amavisd-lite, which is supposed to be streamlined version of amavisd-new, suitable for use with Postfix and SpamAssassin. Last time I checked amavisd-lite wasn't in Portage and I haven't tried it yet, but go ahead and try it, if it's a possibility for you.

----------

## ewie

Right now all i can really do is lower the amount of children to 1. Maybe i'll try amavisd-lite out, i really can't stand amavis using this much memory on my little box. Thanx.

----------

## bunder

i hate to bump a year-and-a-half old thread, but i seem to have this problem as well.  was anyone able to find a fix for it?

----------

## bunder

 *bunder wrote:*   

> i hate to bump a year-and-a-half old thread, but i seem to have this problem as well.  was anyone able to find a fix for it?

 

nobody?  if i don't restart it daily, it pigs all my ram and goes into swap.   :Crying or Very sad: 

----------

## dOcBrOwN

The same here ... unfortunately.

----------

## bunder

has anyone figured out why amavis is such a pig?   :Laughing: 

----------

## elgato319

I have amavisd running on at least two machines:

Gentoo - has almost nothing to do

mail-filter/amavisd-new

Installed versions:  2.4.5-r1(08:41:54 04/02/07)(-courier -ldap -milter mysql -postgres -qmail)

```
ps -eo pmem,args,user | sort -nr | grep amavis

16.1 /usr/sbin/clamd             amavis

 1.6 amavisd (master)            amavis

 1.5 amavisd (virgin child)      amavis

 1.5 amavisd (virgin child)      amavis
```

Debian 3.1 - does a lot of spam scanning

$myproduct_name = 'amavisd-new';

$myversion_id = '2.4.5'; $myversion_date = '20070130';

```
ps -eo pmem,args,user | sort -nr | grep amavis

 9.4 amavisd (ch19-30 amavisd

 9.0 amavisd (ch9-ava amavisd

 8.9 amavisd (ch14-av amavisd

 8.9 amavisd (ch12-av amavisd

 8.8 amavisd (ch5-307 amavisd

 8.5 amavisd (master) amavisd

 7.7 /usr/sbin/clamd  amavisd

 7.7 /usr/sbin/clamd  amavisd

 7.7 /usr/sbin/clamd  amavisd

 7.7 /usr/sbin/clamd  amavisd
```

----------

## magic919

It was this kind of thing that made me look for another solution.  I use DSPAM and ClamAV these days.  Even so Clamd benefits from a restart to reduce the memory usage.

----------

## bunder

 *magic919 wrote:*   

> It was this kind of thing that made me look for another solution.  I use DSPAM and ClamAV these days.  Even so Clamd benefits from a restart to reduce the memory usage.

 

don't get me wrong, clamd is a pig too... but amavis is that much more of a pig.   :Wink:   :Laughing: 

----------

## bunder

i updated clamav and amavisd-new recently, and it's even worse now.   :Crying or Very sad: 

----------

## ewie

Well, i decided to get a new box with more memory. So, amavis still hogs memory but I'm not bothered anymore....

```
top - 16:05:41 up 3 days, 16:57,  2 users,  load average: 0.00, 0.02, 0.00

Tasks:  65 total,   1 running,  64 sleeping,   0 stopped,   0 zombie

Cpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st

Mem:   1036540k total,  1006612k used,    29928k free,   106920k buffers

Swap:   369424k total,      544k used,   368880k free,   567448k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND

31542 amavis    16   0 56100  46m 2588 S  0.0  4.6   0:04.21 amavisd

 3916 amavis    16   0 53620  43m 2492 S  0.0  4.3   0:23.18 amavisd

 3236 amavis    16   0 51584  42m 2480 S  0.0  4.2   0:03.92 amavisd

 3401 mysql     15   0  136m  38m 4840 S  0.0  3.8   2:45.67 mysqld

19762 apache    15   0 31696  20m 4708 S  0.0  2.0   0:29.08 apache2

29136 apache    15   0 31836  20m 4352 S  0.0  2.0   0:12.64 apache2

19763 apache    15   0 29240  17m 4580 S  0.0  1.7   0:18.37 apache2

19761 apache    15   0 28444  17m 4860 S  0.0  1.7   0:22.12 apache2

20278 apache    15   0 27464  16m 4600 S  0.0  1.6   0:22.47 apache2

19760 apache    16   0 26964  15m 4684 S  0.0  1.6   0:21.28 apache2

19764 apache    15   0 26660  15m 4404 S  0.0  1.5   0:25.89 apache2

29138 apache    15   0 26440  15m 4516 S  0.0  1.5   0:12.44 apache2

21474 apache    15   0 25924  14m 4732 S  0.0  1.5   0:23.23 apache2

25826 apache    16   0 23512  11m 4468 S  0.0  1.2   0:10.63 apache2

 4144 root      18   0 11916 9564 1716 S  0.0  0.9   1:50.92 mrtg

 3547 root      15   0 20300 9340 3968 S  0.0  0.9   0:00.52 apache2

 3839 postgrey  16   0  9684 7444 2408 S  0.0  0.7   0:08.71 postgrey

19759 apache    16   0 20300 7100 1704 S  0.0  0.7   0:00.00 apache2

19889 root      15   0  6476 3548 1188 S  0.0  0.3   0:16.39 mailgraph.pl

 3292 named     16   0  5744 3292 1968 S  0.0  0.3   0:30.32 named

 3598 root      15   0  4376 3080  588 S  0.0  0.3   0:00.71 saslauthd

10744 cyrus     15   0 32948 2956 2332 S  0.0  0.3   0:00.09 imapd

 3599 root      15   0  4244 2940  568 S  0.0  0.3   0:00.70 saslauthd

10747 cyrus     16   0 32148 2916 2288 S  0.0  0.3   0:00.04 imapd

10862 root      15   0  6956 2208 1772 S  0.0  0.2   0:00.12 sshd

 4337 root      16   0  6376 2108 1492 S  0.0  0.2   0:00.04 smbd

19829 postfix   15   0  6588 1844 1392 S  0.0  0.2   0:01.92 qmgr

 3926 root      15   0  6204 1772 1368 S  0.0  0.2   0:08.46 master

 9940 postfix   16   0  6408 1704 1320 S  0.0  0.2   0:00.06 pickup

10868 root      15   0  2848 1560 1240 S  0.0  0.2   0:00.07 bash

 3743 dhcp      15   0  2936 1464  820 S  0.0  0.1   0:00.20 dhcpd

 3655 cyrus     16   0  4160 1400 1096 S  0.0  0.1   0:00.69 master

 3979 root      15   0  3804 1320  980 S  0.0  0.1   0:06.46 fetchmail

 4347 root      15   0  3760 1188  864 S  0.0  0.1   0:07.40 nmbd

10876 root      16   0  2180 1100  848 R  0.0  0.1   0:00.02 top

 3479 root      16   0  3980 1064  748 S  0.0  0.1   0:00.02 sshd

 4346 root      18   0  6376  896  280 S  0.0  0.1   0:00.00 smbd

 2732 root      15   0  2064  840  524 S  0.0  0.1   0:10.16 syslog-ng

 4403 root      16   0  1940  692  572 S  0.0  0.1   0:00.76 cron

 4887 root      15   0  2080  660  532 S  0.0  0.1   4:07.48 vmware-guestd

 4529 root      16   0  1592  640  552 S  0.0  0.1   0:00.00 agetty

 4530 root      16   0  1592  640  552 S  0.0  0.1   0:00.00 agetty

 4528 root      16   0  1592  636  552 S  0.0  0.1   0:00.00 agetty

 4531 root      16   0  1592  636  552 S  0.0  0.1   0:00.00 agetty

31347 root      16   0  1596  636  552 S  0.0  0.1   0:00.01 agetty

 4527 root      16   0  1596  632  552 S  0.0  0.1   0:00.00 agetty

  395 root      12  -4  1784  580  352 S  0.0  0.1   0:00.24 udevd

 4271 root      15   0  1884  564  448 S  0.0  0.1   0:00.00 rsync

    1 root      16   0  1556  548  476 S  0.0  0.1   0:00.26 init

 4035 root      15   0  1768  396  320 S  0.0  0.0   0:00.09 gpm

    2 root      34  19     0    0    0 S  0.0  0.0   0:00.03 ksoftirqd/0

    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0

    4 root      10  -5     0    0    0 S  0.0  0.0   0:00.10 events/0

    5 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khelper

    6 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kthread

    8 root      10  -5     0    0    0 S  0.0  0.0   0:01.40 kblockd/0

    9 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kacpid

   49 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kseriod

   80 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pdflush

   81 root      15   0     0    0    0 S  0.0  0.0   0:33.19 pdflush

   82 root      15   0     0    0    0 S  0.0  0.0   0:01.78 kswapd0

   83 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 aio/0

  167 root      16  -5     0    0    0 S  0.0  0.0   0:00.00 kpsmoused

  212 root      10  -5     0    0    0 S  0.0  0.0   0:03.27 reiserfs/0

  791 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khubd

```

----------

## bunder

ever since that upgrade i've been having to restart amavisd-new and clamav every day or else i'll push heavily into swap.   :Crying or Very sad:   :Crying or Very sad:   :Crying or Very sad: 

----------

