When a Linux database server begins thrashing and slowing down, the first suspect is usually a lack of available memory (RAM). When the server completely runs out of high-speed physical RAM, it forcefully offloads data onto the “swap” partition on the brutally slow mechanical hard drive, resulting in catastrophic latency. To instantly diagnose memory pressure and view the exact ratio of used versus available RAM, you must use the free command.
How to Read the Output of the free Command
The free command parses the complex raw data hidden inside the /proc/meminfo virtual file and formats it into a clean, human-readable terminal table.
Open your terminal and type the command by itself:
free
The terminal will output a small table containing two main rows: Mem: (your physical RAM) and Swap: (your emergency hard drive overflow space). The default output displays numbers in kilobytes, which are massive, incredibly difficult integers to read (e.g., 16382944). To make the table actually useful, append the -h (human-readable) flag:
free -h
The table will now calculate the data dynamically, displaying it in clean Megabytes (M) or Gigabytes (G).
Understanding Linux RAM Caching
When junior administrators run the free command, they often panic when they look at the free column and see that it is almost at zero. They falsely believe the server is entirely out of memory and about to crash.
This is a fundamental misunderstanding of how the Linux kernel operates. Linux intentionally “steals” unused RAM to cache the hard drive filesystem. It aggressively loads frequently accessed files into RAM so they open instantly. This cached data is marked in the buff/cache column.
If a massive database query suddenly requires that RAM, Linux will instantly dump the filesystem cache and hand the memory over to the database. Therefore, the memory is not “gone,” it is simply being borrowed to speed up the system.
The Most Important Column: Available
Because the “free” column is highly misleading, you must completely ignore it. If you want to know how much memory your server actually has remaining before it crashes, look exclusively at the available column located at the far right of the table.
The “available” column calculates the absolute total amount of RAM that is truly unused, plus the amount of RAM that can be instantly reclaimed from the filesystem cache. If the “available” column drops to zero, and you see numbers steadily increasing in the Swap used row, your server is officially out of memory and actively dying.