Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tech:linux:memory_usage [2014/11/15 09:13]
tech:linux:memory_usage [2014/11/15 09:13] (current)
Line 1: Line 1:
 +====== Find Memory Usage ======
 +===== System memory used and free =====
 +Total Used and Free Memory in MBytes (in that order)
 +<​code>​
 +free -m|grep "​buffers/​cache"​|cut -d":"​ -f2
 +</​code>​
 +
 +===== Memory by Process =====
 +Raw
 +<​code>​
 +ps -e -orss=,​args= | sort -b -k1,1n | pr -TW$COLUMNS
 +</​code>​
 +Human readable
 +<​code>​
 +ps -e -orss=,​args= | sort -b -k1,1n | awk '{ split( "KB MB GB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } print int($1) " " v[s] " " $2 }'
 +</​code>​
 +
 +===== Memory by Process - Grouped together =====
 +Raw
 +<​code>​
 +ps -e -orss=,​args= | awk '​{arr[$2]+=$1} END {for (i in arr) {print arr[i],​i}}'​ | sort -b -k1,1n
 +</​code>​
 +Human readable
 +<​code>​
 +ps -e -orss=,​args= | awk '​{arr[$2]+=$1} END {for (i in arr) {print arr[i],​i}}'​ | sort -b -k1,1n | awk '{ split( "KB MB GB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } print int($1) " " v[s] " " $2 }'
 +</​code>​
 +
 +===== Total RSS Memory =====
 +<​code>​
 +ps -e -orss= | awk '{ sum += $1 } END { print sum }'
 +</​code>​
 +Human redable
 +<​code>​
 +ps -e -orss= | awk '{ sum += $1 } END { print sum }' | awk '{ split( "KB MB GB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } print int($1) " " v[s] " " $2 }'
 +</​code>​
 +
 +===== Total Memory =====
 +<​code>​
 +smem -w -t -k
 +</​code>​
 +
 +===== Related =====
 +Use ''​lshw''​ - for listing hardware including physical memory slots
  

QR Code
QR Code tech:linux:memory_usage (generated for current page)