Free memory by flushing pagecache and slabcache
You can free memory on demand with a simple command that clears memory used by the Linux pagecache and slabcache.
Write 1 to /proc/sys/vm/drop_caches to free pagecache, 2 to free dentries and inodes, or 3 to free pagecache, dentries, and inodes.
Examples of freeing or clearing memory
Command to free pagecache:
# sync && echo 1 > /proc/sys/vm/drop_caches
Command to free dentries and inodes:
# sync && echo 2 > /proc/sys/vm/drop_caches
Command to free pagecache, dentries, and inodes:
# sync && echo 3 > /proc/sys/vm/drop_caches
Recommendation: Freeing memory while the server is under heavy memory and I/O load may cause a deadlock.