在Linux下可以使用/proc/meminfo文件查看操作系统内存的使用状态

# cat /proc/meminfo 
MemTotal:       16333852 kB
MemFree:         1633564 kB
Buffers:          212448 kB
Cached:          4422808 kB
SwapCached:            0 kB
Active:         10343096 kB
Inactive:        3784128 kB
Active(anon):    7954776 kB
Inactive(anon):  1537404 kB
Active(file):    2388320 kB
Inactive(file):  2246724 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       2047992 kB
SwapFree:        2047992 kB
Dirty:               672 kB
Writeback:             0 kB
AnonPages:       9491968 kB
Mapped:            34240 kB
Shmem:               212 kB
Slab:             375180 kB
SReclaimable:     316296 kB
SUnreclaim:        58884 kB
KernelStack:       27456 kB
PageTables:        35396 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    10214916 kB
Committed_AS:   19743752 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      303556 kB
VmallocChunk:   34359420140 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       10240 kB
DirectMap2M:    16766976 kB



注意这个文件显示的单位是kB而不是KB,1kB=1000B,但是实际上应该是KB,1KB=1024B

这个显示是不精确的,是一个已知的没有被更正的历史遗留问题。因为很多程序依赖这个文件查看内存使用的是kB字符


MemTotal:       16333852 kB


     MemTotal是可使用内存的总量,单位是KB,物理内存减去一些保留内存和内核二进制代码占用的内存


MemFree:         1633564 kB


     MemFree 剩下没有被使用的物理内存,单位是kibibytes,即KB


 

Buffers:          212448 kB

     Buffers 临时存储原始磁盘块的总量,单位是KB


Cached:          4422808 kB


     Cached 用作缓存内存的物理内存总量,单位是KB



SwapCached:            0 kB


     SwapCached 曾经被移入到swap,然后又回到主内存,但是仍然也在swapfile中保留的总内存大小。这样可以节省I/O,应为内存不需要再移入到swap


Active:         10343096 kB

     Active 最近经常被使用的内存大小总量,单位是KB。


Inactive:        3784128 kB


     Inactive 最近不是经常使用的内存,单位是KB


Active(anon):    7954776 kB

     匿名和tmpfs/shmem内存总量,单位是KB. 自上次系统移动一些什么东西到swap后处于活动使用状态或者之前处于活动使用状态的内存


Inactive(anon):  1537404 kB

     作为候选收回的匿名和tmpfs/shmen内存总量,单位是KB


Active(file):    2388320 kB

     文件缓存内存的总量,单位是KB。处于活动使用状态,或者之前自上次系统召回内存处于活动使用状态的内存

   

Unevictable:           0 kB

      The amount of memeory,in kibibytes,discovered by the pageout code,that is not evictable because it is locked into memeory by user programs.


Mlocked:               0 kB

     因为被用户程序锁住不能被回收的内存总量,单位是KB


SwapTotal:

     swap总量,单位是KB


SwapFree: 

     空闲swap总量

Dirty  等待写回到磁盘内存总量,单位是KB


Writeback   正在写回到磁盘的内存总量,单位是KB


AnonPages   The total amount of memory,in kibibytes,used by pages that are not backed by files and are mapped into userspace page tables


Mapped     The memory,in kibibytes, used for files that have been mmaped,such as libraries


Shmem     The total amount of memeory,in kibibytes,used by shared memeory(shmem) and tmpfs


Slab     The total amount of memeory,in kibibytes,used by the kernel to cache data structures for its own use.



SReclaimable   The part of Slab that can be reclaimed,such as caches.



SUnreclaim    The part of Slab that cannot be reclaimed even when lacking memeory


KernelStack   The amount of memeory,in kibibytes,used by the kernel stack allocations done for each task in the system


PageTables   The total amount of memeory,in kibibytes,dedicated to the lowest page table level.



NFS_Unstable  The amount,in kibibytes,of NFS page sent to the server but not yet committed to the stable storage


Bounce   The amount of memory,in kibibytes,used for the block device "bounce buffers"


WritebackTmp   The amount of memory,in kibibytes, used by FUSE for temporary writeback buffers


CommitLimit   The total amount of memory currently avaiable to be allocated on the system based on the overcommit ratio(vm.overcommit_ratio) This limit is only adhered of if stric overcommit accounting is enabled(mode 2 in vm.overcommit_memory) 


([total RAM pages] - [total huge TLB pages]) * overcommit_ratio
───────────────────────────────────────────────────────────────── + [total swap pages]
                           100

  例如1G的物理内存和7GB的swap内存,vm.overcommit_ratio设置为30,那么CommitLimit 就是7.3GB


Committed_AS   The total amount of memory,in kibibytes,estimated to complete the workload.

          This value repsents the worst case scenario value,and also includes swap memory


VMallocTotal  The total amount of memory,in kibibytes,of total allocated virtual address space


VMallocUsed — The total amount of memory, in kibibytes, of used virtual address space.


VMallocChunk — The largest contiguous block of memory, in kibibytes, of available virtual address space.


HardwareCorrupted — The amount of memory, in kibibytes, with physical memory corruption problems, identified by the hardware and set aside by the kernel so it does not get used.


AnonHugePages — The total amount of memory, in kibibytes, used by huge pages that are not backed by files and are mapped into userspace page tables.


HugePages_Total — The total number of hugepages for the system. The number is derived by dividing Hugepagesize by the megabytes set aside for hugepages specified in /proc/sys/vm/hugetlb_poolThis statistic only appears on the x86, Itanium, and AMD64 architectures.


HugePages_Free — The total number of hugepages available for the system. This statistic only appears on the x86, Itanium, and AMD64 architectures.


HugePages_Rsvd — The number of unused huge pages reserved for hugetlbfs.

HugePages_Surp — The number of surplus huge pages.


Hugepagesize — The size for each hugepages unit in kibibytes. By default, the value is 4096 KB on uniprocessor kernels for 32 bit architectures. For SMP, hugemem kernels, and AMD64, the default is 2048 KB. For Itanium architectures, the default is 262144 KB. This statistic only appears on the x86, Itanium, and AMD64 architectures.


DirectMap4k — The amount of memory, in kibibytes, mapped into kernel address space with 4 kB page mappings.


DirectMap2M — The amount of memory, in kibibytes, mapped into kernel address space with 2 MB page mappings.











参考文档:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-proc-meminfo.html