# free -h
# free -m
total used free shared buff/cache available
Mem: 63783 11837 3768 44544 48177 6514
Swap: 16383 16008 375
The column headers in the free command are somewhat mislabeled, at least from the point of view of a linux user (as opposed to developer). Below is a clarification of what the headings mean:
total: Yes, this is total ram.
used: This is probably the most confused column. This is a mix of application used memory and other 'temporarily' (buffer + cache) used memory that is actually available if needed. So technically the memory is truly being used, but much of this memory is available if an application needs it. The 'temporarily' used memory is borrowed if available by the linux system to help speed up system performance, otherwise the system would have read from disk more often. Much of this type of memory is shown under the 'cached' column. This memory is given up by the linux system if an application need memory.
free: Yes, this pure free and untouched memory.
shared: Memory specifically allocated for use by multiple processes
buffers: Temporary memory that is set aside to help some processes
cache: Memory that is available and 'borrowed' by the operating system to help speed up many linux OS operations. This memory is given up by the system if an application need it.
The line that starts with -/+ buffers/cache is typically more helpful than the first Mem line. The intersection of free and -/+ buffers/cache is essentially what you have for 'available' memory.
available: is an estimate of the amount of memory that is available for starting NEW applications, without using the swap memory.
# ipcs -a - tämä komento näyttää IPC-resurssien käytön, kuten jaetut muistisegmentit. Voit tarkistaa, kuinka paljon muistia IPC-resurssit käyttävät.
------ Message Queues --------
key msqid owner perms used-bytes messages
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x99550690 0 oragrid 600 73728 28
0x00000000 1 oracle 600 8957952 160
0x00000000 2 oracle 600 8945664 116
0x00000000 3 oracle 600 8953856 358
0x00000000 4 oracle 600 6425673728 80
0x00000000 5 oracle 600 3204448256 58
0x00000000 6 oracle 600 25434259456 179
0x00000000 7 oracle 600 7819264 80
0x00000000 8 oracle 600 7831552 58
0x00000000 9 oracle 600 58155008 179
0xd7f884ac 10 oracle 600 61440 80
0x1d1c3990 11 oracle 600 32768 58
0x705baf14 12 oracle 600 61440 179
0x00000000 13 oracle 600 8953856 130
0x00000000 14 oracle 600 6358564864 65
0x00000000 15 oracle 600 7823360 65
0x7e8ce944 16 oracle 600 61440 65
0x00000000 65571 oracle 600 8953856 120
0x00000000 65572 oracle 600 25434259456 60
0x00000000 65573 oracle 600 58155008 60
0xbc04c828 65574 oracle 600 61440 60
------ Semaphore Arrays --------
key semid owner perms nsems
0x91b97270 7 oragrid 600 250
0x91b97271 8 oragrid 600 250
0x5ebae448 12 oracle 600 250
0x5ebae449 13 oracle 600 250
0x5ebae44a 14 oracle 600 250
0x112185a0 18 oracle 600 250
0x112185a1 19 oracle 600 250
0x112185a2 20 oracle 600 250
0xf4f5ac50 24 oracle 600 250
0xf4f5ac51 25 oracle 600 250
0xf4f5ac52 26 oracle 600 250
0xd60eb8b4 30 oracle 600 250
0xd60eb8b5 31 oracle 600 250
0xd60eb8b6 32 oracle 600 250
0xc4010a7c 98360 oracle 600 250
0xc4010a7d 98361 oracle 600 250
0xc4010a7e 98362 oracle 600 250
yhdistämällä free -m ja ipcs -a tiedot voit arvioida jäljellä olevan muistin seuraavasti:
käytettävissä oleva muisti free -m komennosta.
IPC-resurssien käyttämä muisti ipcs -a komennosta.
todellinen jäljellä oleva muisti = available muisti - IPC-resurssien käyttämä muisti.
käytettävissä olevan muistin seuraavien tietojen perusteella:
free -m komennon tulos:
käytettävissä oleva muisti: 6514 MB
ipcs -a komennon tulos: (punaisella merkityt)
jaetut muistisegmentit käyttävät yhteensä noin 63936.34 MB muistia.
todellinen käytettävissä oleva muisti on:
6514 MB − 63936.34 MB = −57422.34MB
näyttää siltä, että jaetut muistisegmentit käyttävät enemmän muistia kuin mitä on käytettävissä, mikä johtaa negatiiviseen arvoon. tämä voi viitata siihen, että järjestelmässä on muistinkäyttöön liittyviä ongelmia.
overall_swap_usage.sh
#!/bin/bash
# Get current swap usage for all running processes
# Erik Ljungstrom 27/05/2011
# Modified by Mikko Rantalainen 2012-08-09
# Pipe the output to "sort -nk3" to get sorted output
# Modified by Marc Methot 2014-09-18
# removed the need for sudo
SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d -regex "^/proc/[0-9]+"`
do
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm --no-headers`
for SWAP in `grep VmSwap $DIR/status 2>/dev/null | awk '{ print $2 }'`
do
let SUM=$SUM+$SWAP
done
if (( $SUM > 0 )); then
echo "PID=$PID swapped $SUM KB ($PROGNAME)"
fi
let OVERALL=$OVERALL+$SUM
SUM=0
done
echo "Overall swap used: $OVERALL KB"
# for file in /proc/*/status ; do awk '/Tgid|VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | grep kB | sort -k 3 -n