0

This is the output of free -h command on my Ubuntu 18.04 laptop:

$ free -hg
              total        used        free      shared  buff/cache   available
Mem:            11G        4,2G        3,4G        801M        4,0G        6,3G
Swap:           11G          0B         11G

From what I understand after a short research using mostly stackexchange sites (e.g. this elaboration), the main difference between free and available memory is that free is actually free and available can become free if the need arises.

What is the process via which the available memory is allocated to a task that creates the relevant need?

Does flushing dirty pages and freeing up cache (to allocate the memory freed up to a process that requires it) constitute part of such a process?

In such a case I assume available should always be > cache.

1 Answer 1

4

It’s a bit more complicated than that. Available memory is memory which is immediately reclaimable, i.e. can be re-purposed without losing data, minus certain thresholds below which the system swaps. This doesn’t include dirty pages, since they need to be written out, and that can take a lot of time.

See the above link for details. In particular, the existence of thresholds, and the fact that “buff/cache” includes dirty pages, means that there is no guarantee that the available memory is larger than the amount given under “buff/cache”.

2
  • However can't the mmanagement module free memory from inactive(file), thus by flushing cache to hard disk? "inactive :The amount of inactive memory (in KB), or memory that has not been used for a while and is eligible to be swapped to disk." (from: bit.ly/2OTM4VW)
    – pkaramol
    Nov 17, 2018 at 20:17
  • 1
    “Inactive(file)” represents the inactive part of the page cache, i.e. file-backed memory which hasn’t been used recently. It isn’t dirty, so it can be discarded at any time (the data is stored elsewhere already). Nov 17, 2018 at 22:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .