Memory Allocation on Linux

Linux 内存分配过程:
free -> buff/cache -> swap

~]# free -g
total used free shared buff/cache available
Mem: 7 1 5 0 0 5
Swap: 5 0 5

Top swap usage of processes.

for file in /proc/*/status; do awk '/VmSwap|Name|^Pid/{printf $2 " " $3}END{print ""}' $file; done | sort -k 3 -n -r | head

内存不足,无法满足程序需求时,会发生内存溢出,进而导致系统杀死当前占用最多内存的进程。
Out of memory: killed process