我似乎只使用了总内存的一部分

我似乎只使用了总内存的一部分

我的 Kubuntu 笔记本电脑

 $ uname -a
   Linux jiggs 3.16.0-31-generic #43-Ubuntu SMP Tue Mar 10 17:37:36 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

有 6GiB 内存:

  # lshw -C memory
   *-firmware              
   description: BIOS
   vendor: TOSHIBA
   physical id: 0
   version: Version 6.50
   date: 11/26/2012
   size: 128KiB
   capacity: 8128KiB
   capabilities: isa pci pnp upgrade shadowing vesa cdboot bootselect edd int13floppytoshiba int13floppy720 int5printscreen int9keyboard int14serial int17printer acpi usb biosbootspecification netboot
  *-memory
   description: System Memory
   physical id: 1f
   slot: System board or motherboard
   size: 6GiB
  *-bank:0
      description: SODIMM DDR3 Synchronous 1600 MHz (0,6 ns)
      product: HMT351S6CFR8C-PB
      vendor: Hynix/Hyundai
      physical id: 0
      serial: 3F720214
      slot: DIMM0
      size: 4GiB
      width: 64 bits
      clock: 1600MHz (0.6ns)
   *-bank:1
      description: SODIMM DDR3 Synchronous 1600 MHz (0,6 ns)
      product: HMT325S6CFR8C-PB
      vendor: Hynix/Hyundai
      physical id: 1
      serial: 046584F8
      slot: DIMM2
      size: 2GiB
      width: 64 bits
      clock: 1600MHz (0.6ns)

据我推断,我有 6GiB(根据我购买时的规格记忆)。

然而,其他文书却有不同的报告:

  $ vmstat -s
  4942348 K total memory
  3043944 K used memory
  1591504 K active memory
  1160736 K inactive memory
  1898404 K free memory
    93484 K buffer memory
   810816 K swap cache
  4194300 K total swap
   242832 K used swap
  3951468 K free swap
  7151425 non-nice user cpu ticks
    22453 nice user cpu ticks
   401211 system cpu ticks
 94036935 idle cpu ticks
    62616 IO-wait cpu ticks
      246 IRQ cpu ticks
     3030 softirq cpu ticks
        0 stolen cpu ticks
  1570974 pages paged in
  9494712 pages paged out
     1695 pages swapped in
    18084 pages swapped out
 87647428 interrupts
199120848 CPU context switches
1426162570 boot time
    41765 forks

或者

 $ free -h
              total       used       free     shared    buffers     cached
Mem:          4,7G       2,9G       1,8G       209M        91M       796M
-/+ buffers/cache:       2,0G       2,7G
Swap:         4,0G       237M       3,8G

或者,最后,

 $ cat /proc/meminfo 
 MemTotal:        4942348 kB                                                                                                                                                                                                                                                    
 MemFree:         1892556 kB                                                                                                                                                                                                                                                    
 MemAvailable:    2483472 kB                                                                                                                                                                                                                                                    
 Buffers:           93844 kB                                                                                                                                                                                                                                                    
 Cached:           815388 kB                                                                                                                                                                                                                                                    
 SwapCached:       180524 kB                                                                                                                                                                                                                                                    
 Active:          1595312 kB                                                                                                                                                                                                                                                    
 Inactive:        1162484 kB                                                                                                                                                                                                                                                    
 Active(anon):    1128632 kB                                                                                                                                                                                                                                                    
 Inactive(anon):   934308 kB                                                                                                                                                                                                                                                    
 Active(file):     466680 kB                                                                                                                                                                                                                                                    
 Inactive(file):   228176 kB                                                                                                                                                                                                                                                    
 Unevictable:          68 kB                                                                                                                                                                                                                                                    
 Mlocked:              68 kB                                                                                                                                                                                                                                                    
 SwapTotal:       4194300 kB                                                                                                                                                                                                                                                    
 SwapFree:        3951468 kB                                                                                                                                                                                                                                                    
 Dirty:                 0 kB                                                                                                                                                                                                                                                    
 Writeback:             0 kB                                                                                                                                                                                                                                                    
 AnonPages:       1671124 kB                                                                                                                                                                                                                                                    
 Mapped:           296016 kB                                                                                                                                                                                                                                                    
 Shmem:            214376 kB                                                                                                                                                                                                                                                    
 Slab:             167272 kB                                                                                                                                                                                                                                                    
 SReclaimable:     130004 kB                                                                                                                                                                                                                                                    
 SUnreclaim:        37268 kB                                                                                                                                                                                                                                                    
 KernelStack:        9552 kB                                                                                                                                                                                                                                                    
 PageTables:        56688 kB                                                                                                                                                                                                                                                    
 NFS_Unstable:          0 kB                                                                                                                                                                                                                                                    
 Bounce:                0 kB                                                                                                                                                                                                                                                    
 WritebackTmp:          0 kB                                                                                                                                                                                                                                                    
 CommitLimit:     6665472 kB                                                                                                                                                                                                                                                    
 Committed_AS:    6178500 kB                                                                                                                                                                                                                                                    
 VmallocTotal:   34359738367 kB                                                                                                                                                                                                                                                 
 VmallocUsed:      354304 kB                                                                                                                                                                                                                                                    
 VmallocChunk:   34359375180 kB                                                                                                                                                                                                                                                 
 HardwareCorrupted:     0 kB                                                                                                                                                                                                                                                    
 AnonHugePages:    638976 kB                                                                                                                                                                                                                                                    
 HugePages_Total:       0
 HugePages_Free:        0
 HugePages_Rsvd:        0
 HugePages_Surp:        0
 Hugepagesize:       2048 kB
 DirectMap4k:       75328 kB
 DirectMap2M:     5027840 kB

最后一个输出可能很重要,因为它确实不是报告任何硬件问题:硬件损坏 = 0 kB。差异从何而来?

编辑:@Sobrique 正确地指出我应该包含 BIOS 信息:

  Total Memory Size   6140MB

编辑2:

 # dmesg | grep Memory
 [    0.000000] Memory: 5957056K/6166700K available (7384K kernel code, 1145K rwdata, 3408K rodata, 1336K init, 1444K bss, 209644K reserved)
 [    1.201086] [drm] Memory usable by graphics device = 2048M

答案1

奇怪的是,重新启动后,差异不再存在:

 $ dmesg | grep Memory
 [    0.000000] Memory: 5957056K/6166700K available (7384K kernel code, 1145K rwdata, 3408K rodata, 1336K init, 1444K bss, 209644K reserved)
 [    1.312970] [drm] Memory usable by graphics device = 2048M
 $ free -h
              total       used       free     shared    buffers     cached
Mem:          5.7G       3.8G       1.9G       334M       274M       1.6G
-/+ buffers/cache:       1.9G       3.8G
Swap:         6.0G         0B       6.0G
  $ vmstat -s | head -1
  5987640 K total memory
  $ head -1 /proc/meminfo
  MemTotal:        5987640 kB

我当然松了一口气,但也很好奇:我不知道什么可能会导致可用内存暂时减少。

答案2

4G是一个特殊的数字,因为它是2^32。这是一个很好的指标,表明根本原因可能在哪里。遇到 32 位和 31 位内存限制的情况并不罕见。你已经超越了这个 - 你使用的是 4.7G - 所以这对你的 32 位来说不是问题。

经过一番挖掘,我们发现为显卡保留系统 RAM 的情况并不少见。

https://askubuntu.com/questions/82917/ubuntu-detects-only-3-2gb-ram-on-a-64bit-os

要么是这样,要么与 BIOS 相关:

https://askubuntu.com/questions/80721/only-3-2-gb-of-memory-being-used-on-a-64-bit-system http://forums.fedoraforum.org/showthread.php?t=297556

相关内容