Which “free” is really free?

Recently I lend my RPI to a colleague, model B with 512MB of memory, out of which 64MB is dedicated to GPU unit. He was primarily interested on how much memory is actually available to user space after the OS boots (running fresh Raspbian). I told him to simply run “free -m” and he’ll find out that there should be “plenty” of RAM free for user processes. He replied with some sadness, that he expected a bit more than a mere ~200MB of “free” memory. I knew that the problem is not in the Raspbian distro, but rather in the misleading interpretation of the “free” column. This topic is covered so many times on the net that it is actually hard to find short explanation with some graphical illustration. Here is my version compiled from various sources on the net, the most important one being excellent Bruce Momjian blog from PostgreSQL community.

Let’s start with bare “free -m” output taken on my RPI:


Command returns three lines. The first line “Mem:” shows memory from kernel perspective. Kernel sees 233 MB of “free” memory. This memory is not allocated for anything, it just sits there being ready to be used. It’s this number that my friend interpreted as being the only memory that can be used by user programs and processes.

To help get the proper interpretation of free command I prepared a small illustration showing which values are added together.


On my RPI 152 MB of memory is dedicated for caching and 21 MB for buffers.

Second line is a look at the memory from process perspective rather than kernel. This is the line of interest. 30MB is used by running processes. With -/+ the “free” is trying to point out that buffer/cache has been removed (-) from “used” column and added (+) to “free” column. Why? Because the second line as I pointed above looks at memory from process perspective and any process can get portion of memory from buffer/cache if needed. So, having 408MB of free memory for user processes on my RPI looks much better than 233MB :-).

The “shared” column shows how much memory is shared by multiply processes and it’s 0 on my RPI, as well as on my other Linux boxes. (Perhaps this column is simply deprecated on recent kernel versions!?)

Also note that kernel reserves for itself at boot some portion of memory, which is not shown as part of the “Total”.


Posted on 16.04.2013, in Linux, PostgreSQL, etc. and tagged . Bookmark the permalink. Comments Off on Which “free” is really free?.

Comments are closed.