The knowledge base / All cheat sheets
● Always in your toolkitAbout the project ↗

Linux memory pressure investigation cheat sheet

Compare available memory, swap, process usage and kernel messages when a Linux host slows down.

Linux with procps utilities and systemd journal access. Container limits can differ from host totals.

Updated · Linux · 6 min read

CommandWhat it does
free -hInspect memory and swap totals
cat /proc/meminfoRead detailed kernel memory accounting
ps -eo pid,comm,rss --sort=-rssList processes by resident memory
journalctl -k --since "1 hour ago" -n 100 --no-pagerInspect recent kernel messages
systemctl --failed --no-pagerList systemd units in failed state

Walkthrough

Use authorized read access on the affected host. Commands provide point-in-time evidence and do not clear caches, kill processes or change memory limits.

Step 1: Inspect memory and swap totals

free -h

Compare the available memory estimate and swap use with the host baseline. Low free memory by itself is not proof of pressure because the kernel also uses memory for cache.

Step 2: Read detailed kernel memory accounting

cat /proc/meminfo

Inspect MemAvailable, SwapTotal and SwapFree alongside the host’s context. Values are point-in-time counters; compare repeated samples and monitoring rather than inferring a trend from one reading.

Step 3: List processes by resident memory

ps -eo pid,comm,rss --sort=-rss

Compare resident set sizes and identify process owners. RSS values are not additive accounting of unique memory because shared pages can be counted in multiple processes.

Step 4: Inspect recent kernel messages

journalctl -k --since "1 hour ago" -n 100 --no-pager

Look for memory-related events within the incident window. An absent message does not exclude prior pressure if journal permissions, retention or the selected time window hide it.

Step 5: List systemd units in failed state

systemctl --failed --no-pager

Check for failed services around the incident. A failed unit does not by itself establish an out-of-memory cause; correlate service and kernel logs with timestamps.

WORKED INCIDENT

Practical case: A server slows down and a service exits

Fictional teaching scenario; observations are examples, not captured production output.

Situation

An application stops responding during a period of unusually high host memory consumption.

Investigation sequence

1. Inspect memory and swap totals

free -h

Capture available memory and swap usage at the time of the incident.

2. List processes by resident memory

ps -eo pid,comm,rss --sort=-rss

Identify the highest resident-memory processes and their owners.

3. Inspect recent kernel messages

journalctl -k --since "1 hour ago" -n 100 --no-pager

Check the kernel journal for memory-related events during the same window.

4. List systemd units in failed state

systemctl --failed --no-pager

Inspect failed unit status and correlate it with the application timeline.

Example findings

Illustrative findings: available memory drops sharply and the kernel journal records an out-of-memory kill affecting the application.

Interpret the findings

The kernel event supports a memory-kill diagnosis for that process. Determine whether workload growth, limits or another cause led to the pressure before changing sizing.

Verify the outcome

After the owner applies an approved correction, monitor available memory and application stability over a comparable workload period.

Escalation handoff

Send timed memory samples, affected process identity and relevant redacted kernel messages to the system and application owners.

Primary references

Documented reference; examples above are teaching scenarios. Confirm behavior against your deployed version.