Free memory on Linux-based VPS

Category: Cloud Servers &nbsp

Let’s have a closer look at the output of ‘top’ command. Usually it looks like this:

Mem:   1155072k total,   981032k used,   174040k free,    40396k buffers

Most people think that in this case we have 981032k used memory, and only 174040k free . But that’s not correct, this is global misunderstanding of memory stats and ways that Linux systems work with memory (RAM).

In every Linux-based environment some application runs and uses some memory until application finishes its job. However, some data left by this application is still present in memory just in case another application will need it, so it will work way faster.

This memory block is marked as ‘can be reused’. Using ‘top’ command you will see it as ‘used’, so the correct way to check ‘real’ amount of free RAM is to execute ‘free -m’ command. It’ll give something like:

root@host [~]# free -m
total      used      free    shared    buffers    cached
Mem:          1128        956        171          0        38        720
-/+ buffers/cache:        197        930
Swap:        1023          0      1023

The line you need to look at is “-/+ buffers/cache”, it shows actually used and free memory blocks. The above example shows 930Mb of free RAM.

Save this article