Recently
our systems guys got some Nagios warnings on one of our servers that
it is running out of RAM. When we were logged in to the system yes it
is... it was something like this,
$ free -m total used free shared buffers cached Mem: 1504 1491 13 0 91 764
(not
actual data)
But
what are these buffers and cached, They over consumes my RAM. But
what are the details below that...!!
-/+ buffers/cache: 635 869 Swap: 2047 6 2041
Swap
of course about your disk swap space.. Buffers/cache ..?? After I
google it i just found this post that talks everything about this
matter...
“ Disk
caching makes the system much faster! There are no downsides, except
for confusing newbies. It does not take memory away from applications
in any way, ever! If your applications want more memory, they just
take back a chunk that the disk cache borrowed. Disk cache can always
be given back to applications immediately! You are not low on ram! “
So
it says it is not a problem at all... But for the purpose of removing
warnings on Nagios I wanted to clear this cache memory. So this is
the command for that;
sync;
echo 3 > /proc/sys/vm/drop_caches
explanation
of this command as follows; Ref:
http://www.linuxinsight.com/proc_sys_vm_drop_caches.html
drop_caches
Writing
to this will cause the kernel to drop clean caches, dentries and
inodes from memory, causing that memory to become free.To free pagecache:
- echo
1 > /proc/sys/vm/drop_caches
- echo
2 > /proc/sys/vm/drop_caches
- echo
3 > /proc/sys/vm/drop_caches
Note: All the credits goes to the actual owners of the references...