memwatch is a read-only Linux memory monitor and terminal TUI for RAM usage,
installed DIMM details, memory bandwidth, and the processes using the most
resident memory. It is useful when you want a lightweight Rust alternative or
companion to tools like free, top, htop, btop, vmstat, dmidecode,
and perf.
The default mode is an interactive terminal UI. A --once mode is also
available for scripts, diagnostics, CI logs, and non-interactive environments.
Use memwatch when you want to:
- Monitor Linux memory usage from a terminal, including used, available, free, cache, buffers, swap, dirty pages, and writeback.
- Find the highest-RSS processes without opening a full process manager.
- Inspect installed RAM, DIMM slots, memory type, manufacturer, and configured memory speed from SMBIOS/DMI data.
- Measure memory bandwidth with Linux perf PMU counters when the hardware and kernel expose usable events.
- Watch Intel uncore IMC memory-controller read/write bandwidth in MiB/s or GiB/s.
- Debug laptop, desktop, workstation, homelab, and server memory behavior without changing kernel settings or killing processes.
- Shows total, used, available, free, buffers/cache, swap, dirty, and writeback
memory from
/proc/meminfo. - Shows installed memory capacity, DIMM locator, memory type, manufacturer, and configured speed when SMBIOS/DMI data is readable.
- Measures memory bandwidth from Linux perf PMU counters when supported by the kernel and hardware.
- Shows aggregate and per-controller read, write, and total bandwidth when those PMU events are available.
- Lists the highest-RSS processes by scanning
/proc/<pid>/status. - Provides interactive TUI and one-shot plain-text report modes.
- Degrades to
N/Avalues and diagnostics when optional data sources are missing, restricted, or unsupported.
Linux memory monitor, terminal memory monitor, Linux RAM monitor, Rust TUI
memory monitor, memory bandwidth monitor, RAM bandwidth monitor, Intel uncore
IMC monitor, Linux perf PMU, perf_event_open, top RSS processes, process memory
usage, DIMM information, memory speed monitor, SMBIOS memory, DMI memory,
dmidecode, /proc/meminfo, /proc process monitor.
Run from the repository without installing:
cargo run -- --once
cargo run -- --interval 500msBuild and install the release binary:
make install
memwatch --once
memwatchIf /usr/local/bin is not in your PATH, either add it or install with a custom
PREFIX, BINDIR, or INSTALL_PATH.
memwatch targets Linux systems that expose memory and process data through
procfs, SMBIOS/DMI data through sysfs or dmidecode, and bandwidth events
through Linux perf PMUs.
| System type | Support level | Notes |
|---|---|---|
| Bare-metal Linux on Intel x86/x86_64 with uncore IMC PMUs | Full | Expected to show memory usage, DIMM details, top RSS processes, and read/write/total memory bandwidth when permissions are set up. |
| Linux on Intel x86/x86_64 without IMC PMUs | Partial | Memory usage, DIMM details, and top RSS processes may work. Bandwidth shows N/A with a diagnostic. |
| Linux on AMD x86/x86_64 | Partial | Memory usage, DIMM details, and top RSS processes may work. Bandwidth support is limited to available CPU PMU fallback events and may only report read-side activity. |
| Linux VMs, containers, or restricted hosts | Partial | /proc/meminfo usually works, but DMI tables and hardware PMU counters are often hidden or blocked. |
| Non-x86 Linux | Partial | Basic /proc memory and process data may work. DIMM and bandwidth data depend on platform firmware and PMU support. |
| macOS, Windows, BSD, WSL without Linux hardware sysfs/perf access | Not supported for useful runtime data | The crate may compile on some non-Linux targets, but the monitor expects Linux /proc, /sys, and perf hardware-counter interfaces. |
The TUI requires an interactive terminal. Use --once for automation or
non-interactive environments.
| Data | Source |
|---|---|
| System memory summary | /proc/meminfo |
| Top RSS processes | /proc/<pid>/status |
| Direct DMI/SMBIOS table | /sys/firmware/dmi/tables/DMI |
| DMI fallback | dmidecode --type memory |
| PMU event metadata | /sys/bus/event_source/devices |
| CPU online list for AMD fallback PMU events | /sys/devices/system/cpu/online |
| Memory bandwidth counters | perf_event_open |
memwatch does not change memory timings, kernel tunables, process state, swap
settings, or any other system configuration.
Required for building:
- A current stable Rust toolchain.
- Cargo.
The manifest does not currently declare a minimum supported Rust version. Use the
repository's Cargo.lock for reproducible dependency versions.
Optional but recommended:
make, for the repository build/install targets.sudo,setcap, andgetcap, for installing the binary with Linux file capabilities.dmidecode, as a fallback when direct DMI table reads are unavailable or return no installed memory-device records.
On Debian or Ubuntu-style systems, the optional runtime tools are typically in:
sudo apt install make libcap2-bin dmidecodeOn Fedora-style systems:
sudo dnf install make libcap dmidecodeDistribution package names vary. If setcap, getcap, or dmidecode are not
in PATH, install the package that provides them for your distribution.
Build a debug binary:
cargo buildBuild an optimized release binary:
cargo build --releaseThe release binary is written to:
target/release/memwatchThe Makefile wraps the release build:
make buildBuild Debian and RPM packages:
make package VERSION=0.1.12
make check-packages VERSION=0.1.12Package artifacts are written to dist/ by default:
memwatch_0.1.12_amd64.debmemwatch-0.1.12-1.x86_64.rpm
Both packages install memwatch to /usr/bin/memwatch, keep the binary
executable, and run this during package installation:
setcap cap_perfmon,cap_dac_read_search+ep /usr/bin/memwatchRequired package build tools:
dpkg-deb, usually provided by the Debian or Ubuntudpkgpackage.rpmbuild, usually provided by the Fedora, RHEL, or Debianrpmpackage.
Run the full local check suite:
make checkThat runs:
cargo fmt --check
cargo test
cargo clippy -- -D warningsYou can also run individual targets:
make fmt
make test
make clippyThe recommended install path is through the Makefile:
make installBy default this:
- Builds
target/release/memwatchif needed. - Installs it to
/usr/local/bin/memwatch. - Applies the
cap_perfmon,cap_dac_read_search+epfile capability set. - Prints the resulting capability with
getcap.
Verify the installed command:
command -v memwatch
memwatch --onceIf you prefer to run the privileged install step explicitly, build first and
then run install under sudo:
make build
sudo make installThe prebuild matters because sudo make install runs as root and the Makefile
expects the release binary to already exist in that case.
Install under a different prefix:
PREFIX="$HOME/.local" make installInstall to a specific binary directory:
BINDIR="$HOME/.local/bin" make installInstall to an exact path:
INSTALL_PATH="$HOME/.local/bin/memwatch" make installTo install only the binary:
make install-binaryWithout capabilities, memwatch still runs, but DMI details and memory
bandwidth counters may be unavailable.
You can apply or reapply capabilities later:
make capabilityCheck the installed capabilities:
make show-capability
getcap "$(command -v memwatch)"Remove the installed binary:
make uninstallYou can also install with Cargo:
cargo install --path .Cargo does not apply Linux file capabilities. If you need protected DMI table
reads or perf counter access, apply the capabilities manually or use
make install.
The memory summary and top-RSS process list rely on /proc:
test -r /proc/meminfo
ls /proc/1/statusThese data sources normally work as an unprivileged user on Linux. Some containers or hardened hosts may hide process details for other users.
memwatch first tries to read SMBIOS/DMI memory-device records directly from:
/sys/firmware/dmi/tables/DMIIf that does not return installed memory-device records, it falls back to:
dmidecode --type memoryDirect DMI table reads and dmidecode commonly require elevated privileges or
the cap_dac_read_search+ep file capability. If DIMM details show as N/A, use
the Makefile install path or check the source manually:
sudo dmidecode --type memoryBandwidth readings use Linux perf hardware counters. memwatch discovers events
under:
/sys/bus/event_source/devicesOn Intel systems, full bandwidth support expects uncore_imc_* or
uncore_imc_free_running_* event-source devices with exported read and write
events. Check for them with:
ls /sys/bus/event_source/devices | grep uncore_imcThe binary opens PMU counters with perf_event_open. The Makefile applies:
cap_perfmon,cap_dac_read_search+epcap_perfmon is the relevant capability for perf counter access on kernels that
support it. Even with this capability, the kernel may still block access through
perf policy. Check the current policy:
cat /proc/sys/kernel/perf_event_paranoidIf bandwidth remains N/A, run a one-off diagnostic as root:
sudo target/release/memwatch --onceSome systems do not expose memory-controller PMU events at all. In that case the
rest of the monitor still works and the bandwidth panel reports N/A.
Some filesystems, package managers, or copy operations do not preserve Linux file capabilities. If the installed binary is replaced after install, run:
make capabilityIf setcap rejects cap_perfmon, your kernel or libcap tooling may be too old
for that capability name. Basic memory reporting still works without it, but
hardware bandwidth counters will likely remain unavailable.
Start the interactive TUI:
memwatchExit the TUI with any of:
qEscCtrl-C
Use a custom update interval:
memwatch --interval 500ms
memwatch --interval 2sPrint one text report and exit:
memwatch --onceUse a custom sampling interval for the one-shot report:
memwatch --once --interval 250msIn --once mode, memwatch takes an initial sample, waits for the interval,
then takes a second sample so bandwidth can be computed from counter deltas.
Show CLI help:
memwatch --helpCurrent options:
Usage: memwatch [OPTIONS]
Options:
--interval <INTERVAL> [default: 1s]
--once
-h, --help Print help
meminfo unavailable or unreadable: the process cannot read/proc/meminfo. This usually means the program is running outside Linux or inside an unusually restricted environment.DMI table unreadable: direct SMBIOS/DMI table reads failed. Install withmake install, check capabilities withgetcap "$(command -v memwatch)", or verifysudo dmidecode --type memory.dmidecode unavailable: installdmidecodeif you want the fallback path for DIMM details.no memory bandwidth PMU events found: the kernel did not expose supported PMU events. Basic memory and process reporting can still work.failed to open ...: PMU events were discovered, butperf_event_openwas blocked or failed. Check capabilities and/proc/sys/kernel/perf_event_paranoid.- Bandwidth shows
N/Aon the first update: bandwidth requires two counter samples. Wait for the next interval, or use--oncewith a nonzero interval. - Top RSS is empty:
/procprocess status files may be hidden or inaccessible in the current environment. - The TUI does not render correctly: use a real interactive terminal with enough
width and height, or use
memwatch --oncefor plain text output.
src/main.rs: binary entry point.src/lib.rs: mode selection, TUI loop, and terminal lifecycle.src/cli.rs: command-line options.src/memory.rs:/proc/meminfoparsing and memory summary calculations.src/dmi.rs: direct SMBIOS/DMI parsing anddmidecodefallback parsing.src/bandwidth.rs: PMU event discovery, perf counter setup, and bandwidth calculations.src/processes.rs:/proc/<pid>/statusscanning and top-RSS sorting.src/snapshot.rs: combined sampling state.src/render.rs: TUI rendering and one-shot text reports.Makefile: build, install, capability, and check targets.
For the repository About sidebar, useful topics would be:
linux
rust
tui
terminal
memory-monitor
ram-monitor
hardware-monitor
performance-monitoring
memory-bandwidth
perf
pmu
dmidecode
ratatui