Making sense of memory usage on Linux

By  

For example:

:-) free -ms 10
             total       used       free     shared    buffers     cached
Mem:          2026       1922        103          0        491       1109
-/+ buffers/cache:        322       1704
Swap:         4094          0       4094

             total       used       free     shared    buffers     cached
Mem:          2026       1922        103          0        491       1109
-/+ buffers/cache:        321       1704
Swap:         4094          0       4094

             total       used       free     shared    buffers     cached
Mem:          2026       1922        103          0        491       1109
-/+ buffers/cache:        321       1704
Swap:         4094          0       4094

             total       used       free     shared    buffers     cached
Mem:          2026       1922        104          0        491       1109
-/+ buffers/cache:        321       1704
Swap:         4094          0       4094

You would terminate the looping with a ^C. Another option is to use the watch command. This will give you a two-second updated display:

:-) watch free
Every 2.0s: free                                        Sun Jun 10 10:54:55 2012

             total       used       free     shared    buffers     cached
Mem:       2074952    1966704     108248          0     486960    1156036
-/+ buffers/cache:     323708    1751244
Swap:      4192956        128    4192828

You can change the interval used by the watch command by providing a -n # option where # is replaced by a number of seconds (e.g., -n 10).

Another command that will provide you with some information on how your memory is being used is top. While top is one of my all-time favorite commands for looking at performance, even its memory statistics need a little interpretation. Let's begin with the first number on the Mem: and Swap: lines. These are the totals for RAM and swap space and should be consistent with the numbers that we get by looking at the output from the free command. The same holds true of the used and free figures on these lines. Where the top output gets a little confusing is in the buffers and cached figures. Note that we saw these number in the output of the free command, but they were associated with the Mem: statistics, With top, they're on the and Swap: lines.

Photo Credit: 

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Answers - Powered by ITworld

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question