使用sysctl hw.realmem查看实际物理内存:The realmem value is memory before the kernel and modules are loaded, whereas
hw.physmem is what is left after they were loaded.
使用hw.physmem查看去掉kernel和模块调用后剩余的内存
sysctl hw.ncpu是机器的cpu核数
比如这样一台机器:
bash
fb12:/root@[16:22] # sysctl hw.physmem
hw.physmem: 8427704320
fb12:/root@[16:23] # sysctl hw.realmem
hw.realmem: 8589934592
fb12:/root@[16:23] # sysctl hw.ncpu
hw.ncpu: 4
物理内存是8589934592
这是8G的内存,可以在HY中计算,2的33次方就是8589934592
=> (** 2 33)
8589934592