嵌入式系统:我的记忆在哪里?

时间:2012-08-07 17:46:05

标签: linux memory linux-kernel

我有一个基于ARM的嵌入式系统。我只是提出了内核(2.6.34)。以下是一些命令输出。我无法计算整个RAM(128 M)。

内核似乎使用128 MB - 124368 kB = 6704 kB。

Cache = 1672 kB
Slab = 3000 kB

但是MemFree只有100812 kB。如何计算内存的剩余部分(大约18.5 MB)?

还有1512 kB的Committed_AS值表示什么?

# cat /proc/meminfo
MemTotal:         124368 kB
MemFree:          100812 kB
Buffers:               0 kB
Cached:             1672 kB
SwapCached:            0 kB
Active:             1692 kB
Inactive:            284 kB
Active(anon):        304 kB
Inactive(anon):        0 kB
Active(file):       1388 kB
Inactive(file):      284 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 4 kB
Writeback:             0 kB
AnonPages:           328 kB
Mapped:              856 kB
Shmem:                 0 kB
Slab:               3000 kB
SReclaimable:       1116 kB
SUnreclaim:         1884 kB
KernelStack:         248 kB
PageTables:           48 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:       62184 kB
Committed_AS:       1512 kB
VmallocTotal:     876544 kB
VmallocUsed:        1848 kB
VmallocChunk:     873908 kB



# free
             total         used         free       shared      buffers
Mem:        124368        23584       100784            0            0
-/+ buffers:              23584       100784
Swap:            0            0            0



# lsmod
Module                  Size  Used by    Not tainted



# ps
  PID USER       VSZ STAT COMMAND
    1 0         1556 S    init
    2 0            0 SW   [kthreadd]
    3 0            0 SW   [ksoftirqd/0]
    4 0            0 SW   [watchdog/0]
    5 0            0 SW   [events/0]
    6 0            0 SW   [khelper]
   10 0            0 SW   [async/mgr]
  200 0            0 SW   [sync_supers]
  202 0            0 SW   [bdi-default]
  203 0            0 SW   [kblockd/0]
  209 0            0 SW   [ata/0]
  210 0            0 SW   [ata_aux]
  211 0            0 SW   [pxa2xx-spi.2]
  218 0            0 SW   [khubd]
  221 0            0 SW   [kseriod]
  234 0            0 SW   [kmmcd]
  253 0            0 SW   [rpciod/0]
  261 0            0 SW   [khungtaskd]
  262 0            0 SW   [kswapd0]
  264 0            0 SW   [aio/0]
  265 0            0 SW   [nfsiod]
  267 0            0 SW   [crypto/0]
  414 0            0 SW   [mtdblockd]
  457 0            0 SW   [ubi_bgt0d]
  537 0            0 SW   [usbhid_resumer]
  563 0            0 SW   [ubifs_bgt0_0]
  581 0         1556 S    telnetd -l /bin/sh
  586 0         1948 S <  udevd -d
 2956 0         1560 S    -/bin/sh
 3986 0            0 SW   [flush-ubifs_0_0]
 3990 0         4216 R    ps

1 个答案:

答案 0 :(得分:1)

(这是很长时间的评论)

Committed_AS: An estimate of how much RAM you would need to make a
              99.99% guarantee that there never is OOM (out of memory)
              for this workload. Normally the kernel will overcommit
              memory. That means, say you do a 1GB malloc, nothing
              happens, really. Only when you start USING that malloc
              memory you will get real memory on demand, and just as
              much as you use. So you sort of take a mortgage and hope
              the bank doesn't go bust. Other cases might include when
              you mmap a file that's shared only when you write to it
              and you get a private copy of that data. While it normally
              is shared between processes. The Committed_AS is a
              guesstimate of how much RAM/swap you would need
              worst-case.

http://lwn.net/Articles/28345/