The values in /proc/meminfo for MemTotal don't make sense. As a human, eyeballing it, it seems to roughly correspond to the installed RAM, but for using it to display the installed RAM from an automated utility it appears to be inexact, and inconsistent.

For a system with 1G of RAM, I would expect the MemTotal line to have a value of 1048576 - 1024*1024. But instead, I'm seeing 1029392. On another 4G box, I'm seeing 3870172, which is not a multiple of 1024, and it's not even close to 1029392*4. On an 8G box, I get 8128204, which again seems to have no correlation to the other values, nor is it a multiple of 1024.

I'm trying to use this information to report the RAM on a status web page. My work-around is to just "round" it to the nearest 1G multiple, but I'd like to understand why these values seem inconsistent and don't match my expectations.

Can somebody fill me in on what I'm missing here?

EDIT: To expand on the accepted answer below....

The reference can be found here.

Also of interest to me from that page, which explains the inconsistency, is this bit:


Provides information about distribution and utilization of memory. This varies by architecture and compile options. ...


From Documentation/filesystems/proc.txt:

MemTotal: Total usable ram (i.e. physical ram minus a few reserved
          bits and the kernel binary code)

So there you go.


dmesg|grep Memory: will give you a bit more:

$ dmesg|grep Memory:
Memory: 3934184k/5177344k available (4434k kernel code, 1091560k absent, 151600k reserved, 7433k data, 920k init)

Addendum II:

It's also worth adding that pretty much everything in /proc has at least cursory documentation in that file, so it's a good first stop any time you have a similar question.

  • 1
    Thank you! So basically, RTFM. :) Didn't know where to find this info and my Google-Fu let me down. In case anyone else is interested, the above mentioned reference can be found here: kernel.org/doc/Documentation/filesystems/proc.txt – Eric Asberry Jan 7 '11 at 20:40
  • For the record (and the improvement of your Google-Fu): a Google search for "/proc/meminfo" yields exactly this information as the first search result. – larsks Jan 7 '11 at 21:09
  • I confess, I never tried searching for just "/proc/meminfo". Thank you for taking the time to point out my weak Google-Fu. The good news is my search for "meminfo inconsistent" brings up this page now. :) – Eric Asberry Jan 7 '11 at 21:21
  • 1
    interesetingly, when I google for /proc/meminfo now, google takes me here! – kristianlm Mar 17 '15 at 12:47

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.