Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the hueman domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/CloudIngenium.com/htdocs/wp-includes/functions.php on line 6114
How to: Determine your Memory Usage & Free Memory in Ubuntu – Knowledge eXchange

How to: Determine your Memory Usage & Free Memory in Ubuntu

How to: Determine your Memory Usage & Free Memory in Ubuntu

One thing I have discovered with Ubuntu is that there is more than one way to skin a cat. All won’t yield the same result but you can achieve similar things through different approaches. Finding out how much memory you have used, how much is available, and what processes are using the most memory are all possible via different approaches. I will cover some of the commands I generally use but by no means is this list exhaustive. There is probably a better way out there to do some of these tasks I don’t know about, but I feel confident these are pretty common approaches.

I. /proc/meminfo

I don’t use this one often but thought it should be the first one as this is the source for many of the commands I will talk about later. This file stores information about memory usage. I find the following command to be cool as it color codes the output but a simple cat /proc/meminfo is more than enough:

egrep --color 'Mem|Cached|Swap' /proc/meminfo

sample output:

MemTotal: 686872 kB
MemFree: 65540 kB
Cached: 337840 kB
SwapCached: 804 kB
SwapTotal: 4194300 kB
SwapFree: 4186084 kB

II. Free

This is probably my go to command. It tells you how much free memory you have but it is a bit tricky. The first thing to consider is what unit you want the information to be displayed. I started just running free and it output sizes in Kilobytes. Use free -m to display it in megabytes or free -g to show gigabytes. Seems though there is no rounding so if you are using 3.9gb you will get only 3 displayed… seems I am missing something there. Finally, the if you use -t then you get the totals at the bottom.

Using free -t really gives you a picture of what I was saying earlier about the results being tricky. Let’s examine the output of free -m -t first:

total used free shared buffers cached
Mem: 670 607 63 0 92 330
 -/+ buffers/cache: 184 486
Swap: 4095 8 4087
Total: 4766 615 4151

If you look at the used column, adding 607 + 184 + 8 does not equal 615. What you should be focusing on here is the row after Mem:. This rows give you the real memory usage adding or subtracting buffers/cache. So really your system in this case is using 607 mb of memory but most of that is allocated to a buffer/cache. If you monitor the processes you will add up to 184 mb of used memory even though 607mb have been allocated. For all practical purposes the ” -/+ buffers/cache:” row shows how much RAM you’ve used and how much is available to the system.

VMStat is another alternative to Free I don’t use often but you might want to give it a try.

III. Top

Although mostly used by me to monitor CPU usage, you can sort the screen however you see fit and see the processes that use the most memory. It comes installed by default with Ubuntu so you can always count on it. While the screen is displaying the data you can press ? to see what commands are available and how to sort. Use q to quit.

If you like Top, take a look at atop and htop which are similar but you generally have to install them.

Enhanced by Zemanta

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.