vmstat’s Total Memory Statistic

Posted on

Problem :

I am analyzing memory usage on a Linux system. When I run vmstat -s, I see the following:

waffleman@waffle-iron:~$ vmstat -s
      3549184 K total memory
      3206708 K used memory
      1918012 K active memory
      1037320 K inactive memory
       342476 K free memory
       301448 K buffer memory
      1748772 K swap cache
            0 K total swap
            0 K used swap
            0 K free swap
      5481272 non-nice user cpu ticks
       763306 nice user cpu ticks
      3570165 system cpu ticks
    996097114 idle cpu ticks
        72862 IO-wait cpu ticks
           27 IRQ cpu ticks
        35837 softirq cpu ticks
            0 stolen cpu ticks
      1718539 pages paged in
     69439772 pages paged out
            0 pages swapped in
            0 pages swapped out
    460599379 interrupts
   1697890087 CPU context switches
   1314014908 boot time
       307904 forks

I know the system has 4096 MB of RAM installed, but why does it show only 3466 MB? Can this be interpreted as total “available” memory? Perhaps the missing 630 MB is being used by the kernel and cannot paged out?

I also tried this on on an Embedded Linux system and saw a similar result. The DRAM chip has 128 MB, but only 124 MB shows up in vmstat.

Solution :

The “total memory” is the total memory managed by the kernel.

Something else is using that memory or preventing the kernel from using that memory. There are a lot of things it could be. For example, if this is a 32-bit OS without PAE, other mappings may be consuming address space, leaving less than 4GB left. The BIOS uses some memory for structures it populates to pass to the OS. A shared memory video card may consume some memory. And so on.

Leave a Reply

Your email address will not be published. Required fields are marked *