And we're going to take a look now at monitoring our memory.
Now as far as memory, now this might be as far as RAM in our system,
but it could also be swap space.
RAM is going to be the fastest memory to access,
but when we're looking at things like SSD Swap space,
then that can come a close second.
When we look at viewing our memory usage,
I suppose our traditional tool would be the free command,
free ‑h just showing us the correct units for the memory that we have.
We gather the information from our proc file system and our
memory information is in proc/meminfo.
If we wanted to gather how much memory has been utilized over a period of time,
then of course we can go through into our System Activity Reporter,
sar, and ‑r to view our memory statistics.
If we need to go through and find out which applications or
which processes are using the most memory,
then we can go into top.
Now as we've seen before,
we know that top is sorting the processes by the CPU utilization,
but we can use the key f to go to our fields, Arrow Down from CPU to MEM,
choose s for select, and then we can quit to return back to top.
We're now going to be able to see the processes
utilizing the most memory on the system.
So why don't we move out to our command line and take a look
at how we can work with our system RAM,
displaying our memory information and historical information,
as well as then sorting our processes by memory utilization using top.
And here we are with free range to our system,
which reminds us, let's use the command free.
Free will display the available memory including RAM
and swap space, but, obviously,
we have to then try and work out these big numbers.
Using free ‑h, we're able to see that same information,
but within units that we can easily understand.
So it's a good way to get a summary of what we have on our system.
And very often, the memory utilization doesn't necessarily change that often.
All of this information that we're looking at is being dug out
from the proc file system and proc/meminfo.
We can look at the raw information in this file,
but it doesn't look that readable, does it?
So we can see why we tend to use the command free.
Now with that done and dusted and under our belt,
we can also go through and view the information that has
been gathered over a period of time.
So using sar, System Activity Reporter,
we're able to see then the information over a period of time.
When we take a look at it though, there isn't that much of a change.
It really doesn't change that much over the time periods, although it
could do, obviously depending on what we're using, but also if we have a
memory process that is starting to take more and more memory, then we
might be able to detect that, that the memory utilized is becoming
greater over a period of time.
But it's not like looking at our CPUs where we can see our CPU
utilization was changing all of the time.
This is relatively static.
If we are finding though that our memory is going down and we want to
know what's utilizing the memory on our system, then we're able to use
our top command. Now as we already know,
top is sorting by default on the CPU utilization, but if we
use the key f, we can go in and start changing the fields.
When we go through and do that,
clicking f will allow us to then go through and choose
the fields that we want to display.
But if we arrow down and move to our memory and then choose s to sort and
again using q to quit, we return back to top. And now we can see we've got a
far more static display where we're looking at snapd utilizing the most
memory, then followed up by the systemd‑journal. So we're sorting now on those processes utilizing the most memory on our system.