I recently came across a situation where Apache Tomcat cannot start as there was no memory available to allocate to the Java heap (-Xms 1024) when the server had 8GB of physical memory installed. We all know the Linux Kernel borrows unused memory on the system for Disk Cache and releases it when an application needs it. Sadly, things didn’t work out this time and I blame it on Java.
In this instance I had to clear the Disk cache so as to release the memory and Tomcat then started OK.
This is how you do it,
To free pagecache:
# sync; echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
# sync; echo 2 > /proc/sys/vm/drop_caches
To free everything (pagecache, dentries and inodes_:
# sync; echo 3 > /proc/sys/vm/drop_caches