Clamd keeps crashing

Christophe1

Verified User
Joined
Aug 24, 2008
Messages
49
Location
Belgium
Directadmin has been running flawlessly for months on a vps with 2GB ram. I use clamav for scanning email.

Since a few days clamd uses all available memory of the VPS, about 512MB, and then crashes. Again and again in a 1-minute loop:
clamd crashes -> clamd starts again automatically -> clamd reaches 512MB memory usage and crashes again.

Already tried a reinstall of clamav and some tweaks in /etc/clamd.conf (less instances, less connections, smaller queue...), but for now the problem persists.

Does anyone have any suggestions for lowering the memory usage of clamd?
 
less connections, smaller queue
Smaller queue? The more in the queue, the less is done at the same time, so less resources are needed. Maybe raising the queue is better.

I found this on the internet as a possible solution which seemd to be working, also on a VPS with 2 GB ram:
Code:
# clamd.conf
...
#MaxConnectionQueueLength 50
MaxConnectionQueueLength 150
#MaxThreads 50
MaxThreads 5

Next to that, go to /etc/freshclam.conf and lower the amount of updates. It's set to 12 which means every 2 hours by default which also takes resources.
I lowered that in the time I had a VPS set to 2 which means twice a day.
 
Doesn't seem to change anything... Clamd keeps crashing as soon as it reaches about 512MB of memory.

In /tmp/clamd.log, I get:

+++ Started at Fri Aug 4 11:47:25 2017
Received 0 file descriptor(s) from systemd.
clamd daemon 0.99.2 (OS: linux-gnu, ARCH: x86_64, CPU: x86_64)
Log file size limited to 1048576 bytes.
Reading databases from /usr/local/share/clamav
Not loading PUA signatures.
Bytecode: Security mode set to "TrustSigned".
Closing the main socket.
Loaded 6302522 signatures.
TCP: Bound to [127.0.0.1]:3310
TCP: Setting connection queue length to 150
ERROR: daemonize() failed: Cannot allocate memory
Closing the main socket.
 
When scanning an email or even a 1kb file, the memory usage can be between 350mb up to more than 1gb, depending on the amount of rules loaded. According to some stackoverflow posts, clamd will try to allocate at least 512mb and crash if that's not possible. Which sounds like the issue you're having.
 
The problem seems vanished as quickly as it appeared by just giving mysqld a restart.

Mysqld uses about 500MB memory before and after the restart, so there is no difference in available memory.
Clamd seems stable now and uses about 505MB memory. I already did some tests and scanned some folders.
 
Back
Top