Memory (RAM) usage question

To view the available memory I use the command line:

free -h
             total       used       free     shared    buffers     cached
Mem:          7.6G       7.5G        89M        37M       517M       3.5G
-/+ buffers/cache:       3.5G       4.1G
Swap:         4.0G       502M       3.5G

I find this output quite confusing:

  • The “Mem” line implies almost all memory is used.
  • The “buffers” line implies about 1/2 of memory is used
  • The “Swap” line seems to support the “Mem” data since some of the swap is used, but I’d’ve expected more swap usage then.

Could someone point me to a tutorial about these apparently three conflicting bits of data?

On 06/17/2016 02:16 PM, jimoe666 wrote:
>
> To view the available memory I use the command line:
>
> Code:
> --------------------
> free -h
> total used free shared buffers cached
> Mem: 7.6G 7.5G 89M 37M 517M 3.5G
> -/+ buffers/cache: 3.5G 4.1G
> Swap: 4.0G 502M 3.5G
> --------------------
>
> I find this output quite confusing:
> - The “Mem” line implies almost all memory is used.

Linux is smart; unused RAM is a waste of RAM, so it caches things like
disk information in there automatically, which is why you have 3.5G of
cached stuff. One really nice thing about this is that it’s a free
performance boost, but it is also 3.5G of memory available to be used by
applications should they ask for it.

> - The “buffers” line implies about 1/2 of memory is used

See above; this is a nicer number to use for gauging when you should buy
more RAM. Clearly, if this is normal usage for you, you probably do not
need more RAM. Whether or not this is normal, or just after booting, or
after some overly-high load, is something you may want to determine.

> - The “Swap” line seems to support the “Mem” data since some of the swap
> is used, but I’d’ve expected more swap usage then.

You’re not pushing limits, so swap here is just being used as a cache of
stuff that is stale. Until your +/- buffers number gets low, swap should
not be used very much, as you can see here.

There are a lot of threads on various sites (StackOverflow, StackExchange,
etc.) which discuss this too.


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…