I have a CentOS 7 machine and there's a question that bothers me.

When I use lsmem --summary, I get:

Memory block size:       128M
Total online memory:       8G
Total offline memory:      0B

When I use free -h, I get:

              total        used        free      shared  buff/cache   available
Mem:           7.6G        850M        1.7G        361M        5.1G        6.1G
Swap:          7.7G          0B        7.7G

Why is the total memory I get different in the same machine?

What's the difference between these two commands?


lsmem lists memory blocks and their state; these reflect physical memory and are counted in units of memory blocks, i.e. 128MiB on your system. To do this, lsmem reads information made available by the kernel in /sys/devices/system/memory. On your system, the kernel tracks 64 memory blocks for a total of 8GiB.

free lists memory that’s usable by the system; “total” is the amount of physical memory, minus memory reserved by the system (for the firmware’s purposes mostly) and the kernel’s executable code. free reads this information from /proc/meminfo.

The difference in output is explained by this difference in what is measured. In all cases, free’s total memory will be smaller than lsmem’s total online memory.

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.