To check for the overall usage of memory including physical and swap memory, we can use a simple command – free.
You just need to type
free and it will shows you the information of the memory usage. Lets, take mine as an example:
total used free shared buffers cached Mem: 514576 509008 5568 0 59300 95188 -/+ buffers/cache: 354520 160056 Swap: 891568 35424 856144
The value shows at the first line of total column, is the total physical memory I have in kilobytes. i have 512M ram, the results (514,576kb) shown above is approximate in kb. So the system have already used almost all the physically memory, which just left about 5M as free memory.
Out of 354M from 509M that stored in the system, is actually used. And it still left 160M in cache. I have total 891M of swap which is almost double of the size of physical memory I have, and it uses 35M and remain 856M unused.
The memory usage seems high but still consider healthy. I have loaded a lots of applications and uses some minor disc space for swap, but everything still running smooth without any lags.
Free have few options, if you feel that memory result shows in kb is not detail enough, you can have more accurate measurement in bytes. You can passes -b for bytes, or less details -m for Megabytes, -g for gigabytes.
You can ask free to display results in every 5 seconds, in order to track the increases/decreases on memory usage.
free -s 5
Is it free useful?
Reduce your Linux memory footprint written by Martyn Honeyford. The author talks about how you can track the memory usage and he gives suggestions on how to reduce it to the minimum. The first part of the article uses free to do the magic!