diff --git a/Containers/clamav/Dockerfile b/Containers/clamav/Dockerfile index c45d981a..14e5fbf9 100644 --- a/Containers/clamav/Dockerfile +++ b/Containers/clamav/Dockerfile @@ -13,6 +13,15 @@ RUN set -ex; \ sed -i "s|#\?PCREMaxFileSize.*|PCREMaxFileSize 2000M|g" /etc/clamav/clamd.conf; \ # StreamMaxLength must be synced with av_stream_max_length inside the Nextcloud files_antivirus plugin sed -i "s|#\?StreamMaxLength.*|StreamMaxLength 2000M|g" /etc/clamav/clamd.conf; \ +# By default clamd keeps the old signature database in RAM while loading the new one, +# briefly doubling memory usage (~1 GB extra) during each freshclam update cycle. +# Setting ConcurrentDatabaseReload to "no" makes clamd unload the old database first, +# eliminating that transient peak and significantly reducing maximum RAM consumption. + sed -i "s|#\?ConcurrentDatabaseReload.*|ConcurrentDatabaseReload no|g" /etc/clamav/clamd.conf; \ +# The default thread pool is 10-12 threads, each reserving its own stack and scan buffers. +# The Nextcloud antivirus plugin sends one file at a time, so 2 threads are sufficient +# and avoids the idle per-thread memory overhead of the larger default pool. + sed -i "s|#\?MaxThreads.*|MaxThreads 2|g" /etc/clamav/clamd.conf; \ sed -i "s|#\?TCPSocket|TCPSocket|g" /etc/clamav/clamd.conf; \ sed -i "s|^LocalSocket .*|LocalSocket /tmp/clamd.sock|g" /etc/clamav/clamd.conf; \ sed -i "s|Example| |g" /etc/clamav/clamav-milter.conf; \ diff --git a/Containers/clamav/supervisord.conf b/Containers/clamav/supervisord.conf index 1895ceb6..88933ab2 100644 --- a/Containers/clamav/supervisord.conf +++ b/Containers/clamav/supervisord.conf @@ -1,6 +1,5 @@ [supervisord] nodaemon=true -nodaemon=true logfile=/var/log/supervisord/supervisord.log pidfile=/var/run/supervisord/supervisord.pid childlogdir=/var/log/supervisord/