Bog'liq Mastering Ubuntu Server Gain expertise in the art of deploying, configuring, managing, and troubleshooting Ubuntu Server by Jay LaCroix (z-lib.org)
[ 197 ] At first glance, it may appear as though this server has only
179
MB free. You'll see
this in the first row and third column under
free
. In actuality, the number you'll
really want to pay attention to is the number under
available
, which is
1613
MB in
this case. That's now much memory is actually free. Since this server has
1987
MB
of total RAM available (you'll see this on the first row, under
total
), this means that
most of the RAM is free, and this server is not really working that hard at all.
Some additional explanation is necessary to truly understand these numbers.
You could very well stop reading this section right now as long as you take away
from it that the
available
column represents how much memory is free for your
applications to use. However, it's not quite that simple. Technically, when you look
at the output, the server really does have
179
MB free. The amount of memory listed
under
available
is legitimately being used by the system in the form of a cache but
would be freed up in the event that any application needed to use it. If an application
starts and needs a decent chunk of memory in order to run, the kernel will provide it
with some memory from this cache.
Linux, like most modern systems, subscribes to the belief that "unused RAM is
wasted RAM." RAM that isn't being used by any process is given to what is known
as a
disk cache , which is
utilized to make your server run more efficiently. When
data needs to be written to a storage device, it's not directly written right away.
Instead, this data is written to the disk cache (a portion of RAM that's set aside) and
then synchronized to the storage device later in the background. The reason this
makes your server more efficient is that this data being stored in RAM would be
written to and retrieved faster than it would be from disk. Applications and services
can synchronize data to the disk in the background without forcing you to wait for it.
This cache also works for reading data, as when you first open a file, its contents are
cached. The system will then retrieve it from RAM if you read the same file again,
which is more efficient than loading it from the storage volume each time. If you just
recently saved a new file and retrieve it right away, it's likely still in the cache and
then retrieved from there, rather than from the disk directly.
To understand all of the columns shown in
Figure 8.6 , I'll outline the meaning of each
in the following table: