Archive · January 20, 2011

UBUNTU check free memory and free mem empty cache

check memory usage: cat /proc/meminfo or free free command displays amount of total, free and used physical memory (RAM) in the system, as well as shoing information on shared memory, buffers, cached memory and swap space used by the Linux kernel. Syntax of free free -[options] Example usage of free free -m The command will display information about physical memory in MB. free -m -s 5 The command will activate continuous polling delay at 5 seconds apart, and then display memory status in megabytes on terminal. Any floating point number for delay can be specified. free -t -m Same with “free -m”, but -t switch will display a line containing the totals of physical memory and swap space. vmstat vmstat reports report virtual memory statistics, which has information about processes, swap, free, buffer and cache memory, paging space, disk IO activity, traps, interrupts, context switches and CPU activity. With vmstat command, administrators can has instantaneous reports on memory usage. Syntax of vmstat vmstat -[options] [delay count] Example usage of vmstat vmstat The command will display report based on averages since last reboot. vmstat 5 The command will pool average system resources usage level for a sampling period of 5 seconds at interval of 5 seconds, except the first result that is averages since the last reboot. empty / free up memory caches To free pagecache: echo 1 > /proc/sys/vm/drop_caches To free dentries and inodes: echo 2 > /proc/sys/vm/drop_caches To free pagecache, dentries and inodes: echo 3 > /proc/sys/vm/drop_caches As this is a non-destructive operation and dirty objects are not freeable, the user should run "sync" first! This was originally found @ http://www.linuxinsight.com/proc_sys_vm_drop_caches.html