AI Crawler · Collection Records

Bot summary · Last 24 hours

free — Check memory usage

A command that shows physical memory, swap, and buffer/cache usage at a glance.
Markdown source·Anything to add or correct?

💬 "free command"

free shows memory and swap usage. The available value is the indicator used to judge actual available memory.

buff/cache is reclaimable, so a low free value can still be fine.

  • total: Total physical memory.
  • used: Memory used by processes.
  • free: Completely unused memory. This value alone is misleading.
  • available: An estimate of what a new process can use, so look at this value.

Commonly used options

OptionDescription
-hOutput in human-readable units
-m / -gOutput in MB / GB units
-s <seconds>Repeat output every specified number of seconds
-tAdd a total line

3 essential command combinations

  • free -h — Check current memory status (most basic)
  • free -h -s 5 — Repeat every 5 seconds to check trends
  • free -m | awk 'NR==2{print $7}' — Extract the available value for monitoring

💬 "Show me just one example of checking a long-running server"

Here are situations commonly encountered on real production servers, organized in order.

Step 1 · Current status

Check available memory and swap usage.


free -h

Step 2 · Check trends

Use repeated output to see the decreasing trend.


free -h -s 5

Step 3 · Identify the cause

Find processes using a lot of memory.


ps -eo pid,%mem,rss,comm --sort=-%mem | head

How it is used in practice

1. OOM prevention check

Situation — Processes keep dying because memory is low.


free -h && dmesg -T | grep -i oom | tail -3

Result — If available is very low and swap usage is high, the system is short on memory.

Point — Review application memory limits (php-fpm pm.max_children, etc.) or scale the server.

2. Don't panic over cache

Situation — free was nearly 0, so it was mistaken for a failure.


free -h

Result — Confirm that buff/cache accounts for a large portion and that available is sufficient.

Point — Linux uses spare memory as cache, so judge by available.

Important notes

  • A low free value does not immediately mean memory is short. Use available as the basis.
  • Heavy swap usage sharply degrades performance (increased iowait).
  • In container environments, host memory and cgroup limits differ, so be careful.

Actual output

This is the result of checking memory and swap usage.

!free command output: memory and swap usage

An actual production server


Source (HTML): https://games.aidebatehub.com/programs/linux/services/free.html This file is an auto-generated Markdown twin of the DevHub document.

Visitor Comments

Loading…
💬 Comments: 0 · Author type: human | Built: 2026-10-30T20:30:59+09:00