1. 概要
「Linux」には、「free」というコマンドがあって
$ free -h
total used free shared buffers cached
Mem: 3.7G 3.2G 573M 15M 297M 2.1G
-/+ buffers/cache: 808M 3.0G
Swap: 4.9G 61M 4.8G
と直接的にメモリサイズを調べることができるのですが、「FreeBSD」には「free」というコマンドがないので別の方法を使います。
本項は「FreeBSD のメモリ使用量を確認するメモ | work.log」を参考にさせていただきました。
本項、ほぼ、参考サイトのままです。悪しからず。
2. top
「top」コマンド(表示内容は「FreeBSD 11.2 RELEASE」のものです)で
ast pid: 1966; load averages: 0.40, 0.36, 0.29 up 0+02:08:35 19:38:10
22 processes: 1 running, 21 sleeping
CPU: 0.6% user, 0.0% nice, 0.8% system, 1.2% interrupt, 97.5% idle
Mem: 6900K Active, 45M Inact, 283M Wired, 152M Buf, 7592M Free
Swap: 4096M Total, 4096M Free
PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
803 root 2 20 0 6936K 4908K select 0 1:41 1.96% vmtoolsd
1966 root 1 20 0 7920K 3440K CPU1 1 0:00 0.12% top
881 hogehoge 1 20 0 13164K 7904K select 0 0:01 0.04% sshd
355 root 1 20 0 9184K 5040K select 0 0:02 0.04% devd
502 root 1 20 0 6416K 2480K select 0 0:01 0.02% syslogd
887 root 1 20 0 7416K 3752K pause 1 0:00 0.00% csh
878 root 1 22 0 13164K 7764K select 1 0:00 0.00% sshd
882 hogehoge 1 32 0 7416K 3748K pause 1 0:00 0.00% tcsh
774 root 1 20 0 6468K 2476K nanslp 0 0:00 0.00% cron
886 hogehoge 1 22 0 6948K 2992K wait 1 0:00 0.00% su
862 root 1 52 0 6408K 2128K ttyin 1 0:00 0.00% getty
309 root 1 52 0 6548K 2416K select 0 0:00 0.00% dhclient
860 root 1 52 0 6408K 2128K ttyin 0 0:00 0.00% getty
858 root 1 52 0 6408K 2128K ttyin 0 0:00 0.00% getty
861 root 1 52 0 6408K 2128K ttyin 0 0:00 0.00% getty
856 root 1 52 0 6408K 2128K ttyin 0 0:00 0.00% getty
859 root 1 52 0 6408K 2128K ttyin 1 0:00 0.00% getty
857 root 1 52 0 6408K 2128K ttyin 0 0:00 0.00% getty
855 root 1 52 0 6408K 2128K ttyin 1 0:00 0.00% getty
770 root 1 20 0 12852K 7124K select 1 0:00 0.00% sshd
840 root 1 52 0 7304K 3156K select 0 0:00 0.00% ftpd
354 _dhcp 1 27 0 6548K 2532K select 0 0:00 0.00% dhclient
例題だと 4~5行目でメモリサイズがわかります。
3. vmstat
これは少しわかりにくいかも。
$ vmstat
procs memory page disks faults cpu
r b w avm fre flt re pi po fr sr da0 cd0 in sy cs us sy id
1 0 0 136M 7.4G 25 0 0 0 35 3 0 0 7 221 90 0 1 99
4. sysctl
「grep Memory」でフィルタをかけるところが味噌ですね。
$ sysctl -a | grep memory
hw.cbb.start_memory: 2281701376
p1003_1b.memory_protection: 0
p1003_1b.shared_memory_objects: 200112
root@vm.sing.ne.jp /usr/vm > sysctl -a | grep Memory
Virtual Memory: (Total: 157240K Active: 145936K)
Real Memory: (Total: 37060K Active: 35644K)
Shared Virtual Memory: (Total: 20452K Active: 9208K)
Shared Real Memory: (Total: 9108K Active: 7748K)
Free Memory: 7771084K
キロ(K)単位なのがちょっと・・・。
搭載量(実メモリ)はこうやるらしい
$ sysctl hw.physmem
hw.physmem: 8551641088
マニュアルでは -h オプションで人の分かりやすい単位で表示するとのことでしたが、オプションをつけても変化有りませんでした。
5. dmesg
$ dmesg | grep memory
real memory = 8589934592 (8192 MB)
avail memory = 8253632512 (7871 MB)