Linux free command meaning

10.5k Views Asked by At

I got some researh to do about linux. One of the questions is the folowing:

'Is it possible that on a running system the output of the command free in the free column is the same for the first 2 rows? How can you force this?'

I googeled around, and I believe I've found the meaning of these values. If I add buffers and cache together, and add that to free, it gives me the value of free for buffers and cache. Which means, the memory that could be used by applications if required so.

So, I suppose it could be that the values could be the same for those 2 rows, it depends on the usage. But, I've no idea how I could

1

There are 1 best solutions below

0
On

The difference between the first and the second rows is that the first is row is does not count caches and buffers under the free column, while the second one does. Here is an example:

                    total       used       free     shared    buffers     cached
[1]    Mem:       4028712    2972388    1056324          0     315056     835360
[2]    -/+ buffers/cache:    1821972    2206740


used[2] = used[1] - buffers - cached
free[2] = free[1] + buffers + cached

So the answer to your question is: it is possible that these two rows are identical (or at least very close to each other), but not likely on a real system, as it requires you to free/exhaust all the cache. If you are willing to experiment, try some suggestions from how to drop cache or write a program that eats away all available RAM.