free命令:顯示系統使用和空閑的內存情況,包括物理內存、交互區內存(swap)和內核緩沖區內存。
[root@ipha-dev71-1 workspace]# free # kb total used free shared buff/cache available Mem: 16251672 13033660 254336 45824 2963676 2630624 Swap: 16777212 31512 16745700 [root@ipha-dev71-1 workspace]# free -m # MB total used free shared buff/cache available Mem: 15870 12728 248 44 2894 2569 Swap: 16383 30 16353 [root@ipha-dev71-1 workspace]# free -h # -h會自動選擇以適合理解的容量單位顯示 total used free shared buff/cache available Mem: 15G 12G 248M 44M 2.8G 2.5G Swap: 15G 30M 15G
Mem:表示物理內存統計,如果機器剩余內存非常小,一般小於總內存的20%,則判斷為系統物理內存不夠 Swap: 表示硬盤上交換分區的使用情況,如剩余空間較小,需要留意當前系統內存使用情況及負載,當Swap的used值大於0時,則表示操作系統物理內存不夠,已經開始使用硬盤內存了。 第1行數據11G表示物理內存總量;6.5G表示總計分配給緩存(包含buffers與cache)使用的數量,但其中可能部分緩存並未實際使用; 1.3G表示未被分配的內存;shared表示共享內存;4.0G表示系統分配但未被使用的buffers數量;4.7G表示系統分配但未被使用的available數量
top命令:查看系統的實時負載, 包括進程、CPU負載、內存使用等等;
[root@ipha-dev71-1 workspace]# top top - 20:15:25 up 23 days, 22:27, 2 users, load average: 0.01, 0.03, 0.05 Tasks: 173 total, 2 running, 171 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.1 us, 0.1 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 16251672 total, 253612 free, 13034008 used, 2964052 buff/cache KiB Swap: 16777212 total, 16745700 free, 31512 used. 2630252 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 46001 root 20 0 7575660 1.140g 16224 S 0.7 7.4 21:30.36 java 3616 root 20 0 5552312 151452 4008 S 0.3 0.9 93:50.14 beam.smp 46490 root 20 0 8365988 2.075g 16164 S 0.3 13.4 11:18.42 java 48345 root 20 0 8808752 2.448g 20224 S 0.3 15.8 34:00.03 java 78331 root 20 0 6818552 565924 11448 S 0.3 3.5 14:32.37 java 1 root 20 0 191288 3312 2124 S 0.0 0.0 0:51.12 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.33 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:00.53 ksoftirqd/0 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H 7 root rt 0 0 0 0 S 0.0 0.0 0:00.08 migration/0 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh 9 root 20 0 0 0 0 S 0.0 0.0 5:57.72 rcu_sched 10 root rt 0 0 0 0 S 0.0 0.0 0:04.27 watchdog/0
11 root rt 0 0 0 0 S 0.0 0.0 0:03.38 watchdog/1 12 root rt 0 0 0 0 S 0.0 0.0 0:02.14 migration/1