– The /proc filesystem is pseudo filesystem. It does not exist on a disk. Instead, the kernel creates it in memory. It is used to provide information about the system (originally about processes, hence the name).
– The ‘/proc/meminfo‘ is used by to report the amount of free and used memory (both physical and swap) on the system as well as the shared memory and buffers used by the kernel.
– The /proc filesystem is described in more detail in the proc manual page (man proc).
Example of “cat /proc/meminfo”
The output of the command “cat /proc/meminfo” would be different depending on the OS and architecture of the server. The fields listed below may be slightly different or not present in your system.
# cat /proc/meminfo MemTotal: 1882064 kB MemFree: 1376380 kB MemAvailable: 1535676 kB Buffers: 2088 kB Cached: 292324 kB SwapCached: 0 kB Active: 152944 kB Inactive: 252628 kB Active(anon): 111328 kB Inactive(anon): 16508 kB Active(file): 41616 kB Inactive(file): 236120 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 2097148 kB SwapFree: 2097148 kB Dirty: 40 kB Writeback: 0 kB AnonPages: 111180 kB Mapped: 56396 kB Shmem: 16676 kB Slab: 54508 kB SReclaimable: 25456 kB SUnreclaim: 29052 kB KernelStack: 2608 kB PageTables: 5056 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 3038180 kB Committed_AS: 577664 kB VmallocTotal: 34359738367 kB VmallocUsed: 14664 kB VmallocChunk: 34359717628 kB HardwareCorrupted: 0 kB AnonHugePages: 24576 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 69632 kB DirectMap2M: 2027520 kB
The information comes in the form of both high and low statistics. At the top you see a summary of the most common values people would like to look at. Below you find the individual values we will discuss. We will first discuss the high-statistics.
High level statistics
- MemTotal: Total usable ram (i.e. physical ram minus a few reserved bits and the kernel binary code)
- MemFree: Is sum of LowFree+HighFree (overall stat)
- MemShared: 0; is here for compat reasons but always zero.
- Buffers: Memory in buffer cache. mostly useless as metric nowadays Relatively temporary storage for raw disk blocks shouldn’t get tremendously large (20MB or so)
- Cached: Memory in the pagecache (diskcache) minus SwapCache, Doesn’t include SwapCached
- SwapCache: Memory that once was swapped out, is swapped back in but still also is in the swapfile (if memory is needed it doesn’t need to be swapped out AGAIN because it is already in the swapfile. This saves I/O )
1. VM Statistics
VM splits the cache pages into “active” and “inactive” memory. The idea is that if you need memory and some cache needs to be sacrificed for that, you take it from inactive since that’s expected to be not used. The vm checks what is used on a regular basis and moves stuff around.
The statistics are:
- Active: Memory that has been used more recently and usually not reclaimed unless absolute necessary.
- Inact_dirty: Dirty means “might need writing to disk or swap.” Takes more work to free. Example might be files that have not been written to yet. They aren’t written to memory too soon in order to keep the I/O down. For instance, if you’re writing logs, it might be better to wait until you have a complete log ready before sending it to disk.
- Inact_clean: Assumed to be easily free-able. The kernel will try to keep some clean stuff around always to have a bit of breathing room.
- Inact_target: Just a goal metric the kernel uses for making sure there are enough inactive pages around. When exceeded, the kernel will not do work to move pages from active to inactive. A page can also get inactive in a few other ways, e.g. if you do a long sequential I/O, the kernel assumes you’re not going to use that memory and makes it inactive preventively. So you can get more inactive pages than the target because the kernel marks some cache as “more likely to be never used” and lets it cheat in the “last used” order.
2. Memory Statistics
- HighTotal: is the total amount of memory in the high region. Highmem is all memory above (approx) 860MB of physical RAM. Kernel uses indirect tricks to access the high memory region. Data cache can go in this memory region.
- LowTotal: The total amount of non-highmem memory.
- LowFree: The amount of free memory of the low memory region. This is the memory the kernel can address directly. All kernel data structures need to go into low memory.
- SwapTotal: Total amount of physical swap memory.
- SwapFree: Total amount of swap memory free. Memory which has been evicted from RAM, and is temporarily on the disk
- Dirty: Memory which is waiting to get written back to the disk
- Writeback: Memory which is actively being written back to the disk
- Mapped: files which have been mapped, such as libraries
- Slab: in-kernel data structures cache
- 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.
- PageTables: amount of memory dedicated to the lowest level of page tables.
- ReverseMaps: number of reverse mappings performed
- VmallocTotal: total size of vmalloc memory area
- VmallocUsed: amount of vmalloc area which is used
- VmallocChunk: largest contigious block of vmalloc area which is free