Linux 下的实际内存 2000M 还是 2048M?


昨天破血本升级VPS到了 2G 内存; 然后就无意发现 free -m 命令显示的不是 2048M

1
2
3
4
             total       used       free     shared    buffers     cached
Mem:          2001       1614        387         64         96       1011
-/+ buffers/cache:        507       1494
Swap:          255          0        255
             total       used       free     shared    buffers     cached
Mem:          2001       1614        387         64         96       1011
-/+ buffers/cache:        507       1494
Swap:          255          0        255

htop 命令也明显写的是 2000M 左右

 Mem[|||||||||||||||###****************************513/2001MB]

大概是 2000M ,我以为是 QuickHostUK 不厚道,认为 1G = 1000M 但是搞IT的都知道应该用 1024,虽然其实差别也就50M 左右的内存,但是心理很不爽.于是我联系 QuickHostUK;经过一晚上的研究,他们说

1
2
3
4
5
6
7
8
9
10
Hi,
 
Sir system reserves some memory.
Its not an error. 
 
Checking a 4GB (4096MB) vps we see 3820MB.
 
This is kvm virtual server container not a hardware server.
 
Please let us know if you need any further information.
Hi,

Sir system reserves some memory.
Its not an error. 

Checking a 4GB (4096MB) vps we see 3820MB.

This is kvm virtual server container not a hardware server.

Please let us know if you need any further information.

然后我就上网找了一些资料:发现这些命令都是显示可用内存总量并不是物理内存总量.

1
2
3
4
5
6
7
8
9
10
11
root@uploadbeta:/home# cat /proc/meminfo | head
MemTotal:        2049908 kB
MemFree:          388968 kB
Buffers:           99104 kB
Cached:          1048948 kB
SwapCached:            0 kB
Active:           552664 kB
Inactive:         985708 kB
Active(anon):     220912 kB
Inactive(anon):   235604 kB
Active(file):     331752 kB
root@uploadbeta:/home# cat /proc/meminfo | head
MemTotal:        2049908 kB
MemFree:          388968 kB
Buffers:           99104 kB
Cached:          1048948 kB
SwapCached:            0 kB
Active:           552664 kB
Inactive:         985708 kB
Active(anon):     220912 kB
Inactive(anon):   235604 kB
Active(file):     331752 kB

2049908 kB 也是 2001M; 然后这个命令显示了系统总的物理内存.这些信息每次开机都会被记录.

1
2
root@uploadbeta:/home# cat /var/log/dmesg | grep Memory
[    0.000000] Memory: 2041296K/2096748K available (7338K kernel code, 1138K rwdata, 3388K rodata, 1332K init, 1440K bss, 55452K reserved)
root@uploadbeta:/home# cat /var/log/dmesg | grep Memory
[    0.000000] Memory: 2041296K/2096748K available (7338K kernel code, 1138K rwdata, 3388K rodata, 1332K init, 1440K bss, 55452K reserved)

就有显示 总量是 2048M = 2096748K 有一些是系统保留的.

下面的命令 dmidecode -t 17 更清楚的显示物理内存总量:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
root@uploadbeta:/home# dmidecode -t 17
# dmidecode 2.12
SMBIOS 2.4 present.
 
Handle 0x1100, DMI type 17, 21 bytes
Memory Device
        Array Handle: 0x1000
        Error Information Handle: 0x0000
        Total Width: 64 bits
        Data Width: 64 bits
        Size: 2048 MB
        Form Factor: DIMM
        Set: None
        Locator: DIMM 0
        Bank Locator: Not Specified
        Type: RAM
        Type Detail: None
root@uploadbeta:/home# dmidecode -t 17
# dmidecode 2.12
SMBIOS 2.4 present.

Handle 0x1100, DMI type 17, 21 bytes
Memory Device
        Array Handle: 0x1000
        Error Information Handle: 0x0000
        Total Width: 64 bits
        Data Width: 64 bits
        Size: 2048 MB
        Form Factor: DIMM
        Set: None
        Locator: DIMM 0
        Bank Locator: Not Specified
        Type: RAM
        Type Detail: None

好吧,我有点钻牛角尖了,因为自己掏的每一分钱都需要得到回报.

GD Star Rating
a WordPress rating system
本文一共 239 个汉字, 你数一下对不对.
Linux 下的实际内存 2000M 还是 2048M?. (AMP 移动加速版本)
上一篇: 持之与恒
下一篇: 当微软OFFICE启动出现安装窗口时怎么办

扫描二维码,分享本文到微信朋友圈
4d3a462c91e9676d1b67da32ed2e5572 Linux 下的实际内存 2000M 还是 2048M? 折腾 杂乱 网站信息与统计

一条回应

  1. Sligcm

评论