ClamAV consume a lot of memory

Discussion in 'Installation/Configuration' started by Rndoom04, May 24, 2022.

  1. SamTzu

    SamTzu Active Member

    Clam is for Windows users and as such pretty useless since most of them all-ready use some type of Anti Virus software.
    Clam Data Base uses 1G of memory but that doubles to 2G when new DB is loaded.
    You can force dump the old DB before the new is loaded with this configuration change:
    Code:
    echo "ConcurrentDatabaseReload no" >> /etc/clamav/clamd.conf && systemctl restart clam*
    Or even better... just disable it with these commands:
    Code:
    systemctl stop clamav-daemon
    systemctl disable clamav-daemon
    systemctl stop clamav-freshclam
    systemctl disable clamav-freshclam
    PS. Did I say Clam sucks? It's always broken and has trouble updating it self. My gut feeling tells me it's pain that we don't need.
     
    ahrasis and Th0m like this.
  2. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

  3. Sadly I did not find any ClamAV-related config that would limit this,
    however, if you are absolutely sure you want to force this restriction, you could do that by hard restricting the service.

    The ClamAV does have an "extend.conf" file in "/etc/systemd/system/clamav-daemon.service.d".

    There probably already is the "[Service]" section to which you will add some settings according to your decision and I will also drop in some more settings to set up restarting and how often should it restart per hour at maximum.

    Use at your own risk! (config for ClamAV 0.100+) - adjust as you see fit:
    Code:
    [Service]
    # Restart on failure - includes OOM(out of memroy)
    Restart=on-failure
    # CPU priority: niceness (regular policy) and priority(used if real time policy would be also added with CPUSchedulingPolicy)
    CPUSchedulingPriority=60
    Nice=6
    # Hard memory limit - if over => is killed
    MemoryLimit=500M
    ExecStartPre=-/bin/mkdir -p /run/clamav
    ExecStartPre=/bin/chown clamav /run/clamav
    
    [Unit]
    # Max 120 restarts per hour
    StartLimitBurst=120
    StartLimitIntervalSec=1h
    
    Then of course you have to reload the main daemon, stop and start the service again:
    Code:
    sudo systemctl daemon-reload
    sudo service clamav-daemon stop
    sudo service clamav-daemon start
    
     

Share This Page