Find Memory Usage
System memory used and free
Total Used and Free Memory in MBytes (in that order)
free -m|grep “buffers/cache”|cut -d”:” -f2
Memory by Process
Raw
ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS
Human readable
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 }’
Memory by Process – Grouped together
Raw
ps -e -orss=,args= | awk ‘{arr[$2]+=$1} END {for (i in arr) {print arr[i],i}}’ | sort -b -k1,1n
Human readable
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 }’
Total RSS Memory
ps -e -orss= | awk ‘{ sum += $1 } END { print sum }’
Human redable
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 }’
Total Memory
smem -w -t -k
Recent Comments