May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

LINUX MEMORY

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

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>