This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

[6.304] Memory Leak / High memory usage?

Anyone else seeing very high memory usage and what appears to be a slow memory leak with 6.304?

We have a firewall with 1GB RAM and 1GB swap. After a couple days of running swap usage starts creeping up to 200-400MB and then seems to slowly creep up from there. Here is a list of the top memory hogs:

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

 3594 root      34  19  177m 121m 1040 S  0.0 12.0   4:26.09 snmpd
 3677 root      15   0  204m  79m  476 S  0.3  7.8 486:04.31 snort_inline
 4329 chroot    16   0  139m  68m  756 S  0.0  6.8   0:59.56 squidf
 4241 chroot    16   0  105m  66m  812 S  0.0  6.6 104:58.61 clamd
21465 root      16   0 58120  54m 2228 S  0.0  5.4   0:46.15 spamd
21466 root      16   0 58080  54m 2228 S  0.0  5.4   0:37.80 spamd
21461 root      17   0 57792  53m 2224 S  0.0  5.3   0:48.51 spamd
21460 root      16   0 57772  53m 2220 S  0.0  5.3   0:47.47 spamd
21462 root      16   0 57540  53m 2224 S  0.0  5.3   0:43.69 spamd
21464 root      17   0 57048  53m 2228 S  0.0  5.3   0:40.11 spamd
21463 root      16   0 56816  52m 2224 S  0.0  5.2   0:36.41 spamd
21450 root      16   0 51048  47m 2172 S  0.0  4.7   0:01.72 spamd
 2538 root      16   0 54316  37m 2072 S  0.0  3.7  13:58.29 mdw_daemon.pl
32235 root      39  18 42708  37m 1744 R 85.9  3.7  93:48.46 nacctdreport.pl
 7197 root      15   0 47492  22m 2592 S  0.0  2.2  41:03.42 dev-agent.plx
 2223 wwwrun    17   0 26860  20m 3136 S  0.0  2.0   0:00.81 index.fpl
 2353 root      17   0 25168  18m 2824 S 10.7  1.8 863:20.29 confd

Snort, squid, clamd and spamd all seem fairly typical, but snmpd memory on this machine is about 10x higher than my others so that seems to be the culprit.

I'm about to kill it and see what happens, any other suggestions besides a reboot?


This thread was automatically locked due to age.
Parents
  • Here is what free showed before killing snmpd:
                 total       used       free     shared    buffers     cached
    
    Mem:       1034616    1007028      27588          0      17356     182792
    -/+ buffers/cache:     806880     227736
    Swap:      1048816     419196     629620


    And after:
                 total       used       free     shared    buffers     cached
    
    Mem:       1034616     892796     141820          0      19352     157220
    -/+ buffers/cache:     716224     318392
    Swap:      1048816     363424     685392


    So it helped, but only as much as you'd expect (~200MB worth).

    It looks like the spamd processes really suck up a lot of memory, it would be nice to configure them to only start up a 2-3 childs instead of 7.
  • Check your Proxy Content Manager... if you have "tons" of emails in there, in quarantine, I'd suggest reducing the number or days they get to stay there... when the Astaro periodically picks through those, it kicks off extra exim instances if there's a lot to handle.  Also, are you getting a lot of simultaneous SMTP connection attempts?  Those tend to also trigger more exim instances and spamd instances.  Version 7 seems to handle some of this more efficiently, but, of course, there have been some teething (bugs) problems that have slowed it's adoption... it's pretty close to prime time now, may be worth a look for you.
  • Less than 50 emails in the quarantine.

    Not many exim instances, but those are low memory, anyway. 8 spamd instances, 7 children. Those hog over 50MB each so that is 400MB right there and by far the biggest memory hog. They don't appear to be leaking memory, after a fresh start they suck up nearly 50MB each.

    The leaky process appears to be the snmpd process which had sucked up 121MB. After killing it, it uses less than 4MB now.

    Here are top 15 memory hog processes excluding the apparently leaky snmpd. 1st column is total memory for all processes including the ones above it, 2nd column is the memory for the listed proces and 3rd column is the process.

     79 79 snort_inline
    
    147 68 squidf
    213 66 clamd
    267 54 spamd
    321 54 spamd
    374 53 spamd
    427 53 spamd
    480 53 spamd
    533 53 spamd
    585 52 spamd
    632 47 spamd
    669 37 mdw_daemon.pl
    706 37 nacctdreport.pl
    728 22 dev-agent.plx
    748 20 index.fpl


    That is 3/4GB which is a huge amount of memory. Over half of that is for spam filtering. And that doesn't include the leaky snmpd daemon which would have added over 100MB to the bottom line, so it's easy to see why the machine was swapping so heavily. This also doesn't count the other 30-50 processes which use between 1-10MB memory each. It's pretty easy to see that even 1GB is just barely enough for this machine.

    Cutting the number of spam daemons in half and fixing leaking snmpd daemon would be a huge help.

    There's no way we're upgrading to V7. It appears to be much worse memory wise now that it has mysqld running and sucking down over 126MB on our test system. Not to mention it only very recently started getting stable and there is still no migration tools available.

    At least it only starts up 3 spamd children, but our test firewall only has 512MB of memory so I don't know if Astaro automatically adjusts the number of spamd children according to total memory or not.
  • There is a memory metric in place for the spam children in V6, to review or change this:
    joe /var/mdw/scripts/spamassassin

    CHILDREN=2
    MEM=$(expr "$(cat /proc/meminfo)" : ".*MemTotal:[ \t]*\([0-9]*\)")
    [ "$MEM" -gt 1048576 ] && MEM=1048576
    [ "$MEM" -gt 262144 ] && CHILDREN=$[$MEM/131072]

    SPAMDOPTIONS="-d --round-robin --max-children=$CHILDREN"

    Change to = a lower number of children by replacing the $CHILDREN variable with an actual number such as 4

    SPAMDOPTIONS="-d --round-robin --max-children=4"
  • Not a very smart way of determining the number of children to run. Running significantly more spamd processes than the number of processors available doesn't usually buy you anything except for higher peak loads.

    I also wonder why they bother using round-robin, using the default should typically perform better than round-robin.

    Also setting min/max spare and min-children should be useful. Hmm, I wonder why those settings aren't being used by default?

    I've changed my options to this:

    SPAMDOPTIONS="-d --min-children=2 --max-children=$CHILDREN --min-spare=1 --max-spare=2"


    Now normally only 2 children will be running limiting memory usage, but if a spike in mail comes in the system can still fork up to max-children processes to handle the load.
  • There is a memory metric in place for the spam children in V6, to review or change this:
    joe /var/mdw/scripts/spamassassin

    CHILDREN=2
    MEM=$(expr "$(cat /proc/meminfo)" : ".*MemTotal:[ \t]*\([0-9]*\)")
    [ "$MEM" -gt 1048576 ] && MEM=1048576
    [ "$MEM" -gt 262144 ] && CHILDREN=$[$MEM/131072]

    SPAMDOPTIONS="-d --round-robin --max-children=$CHILDREN"

    Change to = a lower number of children by replacing the $CHILDREN variable with an actual number such as 4

    SPAMDOPTIONS="-d --round-robin --max-children=4"
  • Is this done differently in Version 7?
  • CHILDREN=1
    MEM=$(expr "$(cat /proc/meminfo)" : ".*MemTotal:[ \t]*\([0-9]*\)")
    [ "$MEM" -gt 1048576 ] && MEM=1048576
    [ "$MEM" -gt 262144 ] && CHILDREN=$[$MEM/131072]

    SPAMDOPTIONS="-d -u nobody --round-robin --max-children=$CHILDREN"


    Slightly different.  Looks like it runs with a different user level however my 120 is only showing 1 child process available.
Reply
  • CHILDREN=1
    MEM=$(expr "$(cat /proc/meminfo)" : ".*MemTotal:[ \t]*\([0-9]*\)")
    [ "$MEM" -gt 1048576 ] && MEM=1048576
    [ "$MEM" -gt 262144 ] && CHILDREN=$[$MEM/131072]

    SPAMDOPTIONS="-d -u nobody --round-robin --max-children=$CHILDREN"


    Slightly different.  Looks like it runs with a different user level however my 120 is only showing 1 child process available.
Children