brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: lsmem --summary shows how much memory the kernel sees

Memory
~/tips/tip-linux-lsmem-summary

lsmem --summary

Prints the online and offline memory the kernel manages and the size of one memory block.

free tells you what’s used. When I want to know what is actually installed and online, as the kernel sees it, I reach for a different tool that ships with util-linux.

lsmem --summary

The summary shows the total online and offline memory and the size of a single memory block. Without --summary you get the ranges of physical addresses, each with its size, state and whether it is removable.

lsmem -a
lsmem -o +NODE
lsmem -J

-a lists every memory block on its own instead of merging similar ones. -o +NODE adds a column to the default set, and -J gives JSON for scripts. --summary=only is the same as plain --summary.

The caveat: lsmem describes address ranges and blocks, not the sticks in your slots. If you want the modules, their size and speed, use dmidecode -t memory instead. The two answers also won’t match exactly, because the kernel only counts what it manages.

I’d run it next to free -h after adding RAM or changing a VM’s memory. If the total here is lower than you expect, the problem is below the operating system, in the BIOS or the hypervisor settings, and not in your processes.

Further reading: lsmem man page

More Memory tips for f in /proc/[0-9]*/status; do sudo apt install smem sudo pmap -x 1234 sudo systemctl edit indexer.service leaks -atExit — ./myprogram --some-option All Memory tips (12) All topics

Link