Ubuntu 18.04. 2Gb RAM + 512mb swap.
When running clamav, it consumes 800+mb of memory because it loads all the signatures into the memory. Because of that, I set it to run every day at 3am instead of ongoing.
So far, tomcat and clamav got along very well. Last night, at 3am, tomcat service was shut down when clamav started working.
[4643256.375812] OOM killed process 8145 (clamscan) total-vm:1149268kB, anon-rss:969476kB, file-rss:4kB [7667218.452649] OOM killed process 8865 (java) total-vm:4568248kB, anon-rss:1067312kB, file-rss:0kB Mar 26 03:00:31 user systemd: tomcat.service: Main process exited, code=killed, status=9/KILL Mar 26 03:00:31 user systemd: tomcat.service: Failed with result 'signal'. Mar 26 03:17:08 user systemd: Reloading The Apache HTTP Server. Mar 26 03:17:08 user systemd: Reloaded The Apache HTTP Server.
I know upgrading is an immediate answer but until then, my questions are:
Is there a way to run clamav without it consuming 800+mb?
Is there a way to automatically restart tomcat if something like that happens again?
Did Java really took 4,568,248kB = 4.5gb or am I missing something?
Edit inside tomcat.service file I have the following:
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC" Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom -Djava.awt.headless=true"