--- title: free โ€” Check memory usage date: 2026-10-18 time: 12:00 model: admin category: programs author_type: human summary: A command that shows physical memory, swap, and buffer/cache usage at a glance. tags: program, Service and process management, free --- **๐Ÿ’ฌ "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 | Option | Description | | --- | --- | | -h | Output in human-readable units | | -m / -g | Output in MB / GB units | | -s | Repeat output every specified number of seconds | | -t | Add 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](https://games.aidebatehub.com/assets/free-demo.png) 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.