Memory usage apparently higher than expected

avergara08

Registered
Dec 6, 2012
4
0
1
cPanel Access Level
Root Administrator
Hello,

I am kind of new administering whm / dedicated servers. We are currently experiencing a bit of slow down on page load of one of our websites.

I tried checking the server information and service status and I am kind of confused / lost


Code:
Current Memory Usage

             total       used       free     shared    buffers     cached
Mem:       3529860    3275868     253992          0     189112    2329532
-/+ buffers/cache:     757224    2772636
Swap:      4194296         72    4194224
Total:     7724156    3275940    4448216
from here, I see that the free Mem left is only 253992 which I think is a bad thing? Right?

But from service status..
Code:
System information
Server load 	0.14 (4 CPUs) 	
Memory Used 	22.69% (800,964 of 3,529,860) 	
Swap Used 	0% (72 of 4,194,296)
It says only 22% of the memory is used. I am confused. Can someone shed a light for me? Thanks.

Sorry for being tooo noob.
 

MilesWeb

Well-Known Member
PartnerNOC
May 23, 2012
173
2
68
India
cPanel Access Level
Root Administrator
Twitter
If memory is being used, check if any process is consuming a lot of memory. top and ps commands with appropriate options will help to check.
 

JaredR.

Well-Known Member
Feb 25, 2010
1,834
22
143
Houston, TX
cPanel Access Level
Root Administrator
from here, I see that the free Mem left is only 253992 which I think is a bad thing? Right?
No, you have 2772636 KB free. Linux automatically uses RAM that is not being used by applications as buffers and cache. This is a good thing, because it increases the speed of your hard drive subsystem. It automatically reallocates this memory to an application when an application requests it. The number you need to look at is under the "free" column for "-/+ buffers/cache":

Code:
Current Memory Usage

             total       used       free     shared    buffers     cached
Mem:       3529860    3275868     253992          0     189112    2329532
-/+ buffers/cache:     757224    2772636
Swap:      4194296         72    4194224
Total:     7724156    3275940    4448216
The figure in red is the actual memory used, including buffers and cache, and the figure in green, bold, underlined italics is the actual memory free, including buffers and cache.

This is a very, very common misunderstanding, and it is due to the way Linux allocates RAM. The use of free RAM as buffers/cache can make it appear that your server is running out of RAM when it really is not. The following links provide much more information about this:

Gentoo Forums :: View topic - Linux Memory Management or 'Why is there no free RAM?'
Linux Memory Consumption « Real-Time Embedded
Why (on Linux) am I seeing so much RAM usage? | chrisjohnston.org

Based on the output you provided, your server has 2772636 KB of 3529860 KB, or 2.6 GB of 3.4 GB free, so it really has 76% of its RAM free - it is in fine shape, at least at the moment you obtained that free output (free is the command that Home » Server Status » Server Information uses to get memory usage). Always look at the "free" value on the line including buffers/cache to see how much RAM you really have free.

It says only 22% of the memory is used.
That is correct, and it is because it is using the value that includes buffers and cache. My 76% figure added to 22% gives us about 98%, which is about right considering my 76% figure came from rounded numbers. Buffers and cache will be reallocated to an application any time an application needs it, automatically. It is a good thing for server speed that they are used for disk caching when not needed by applications.

By the way, you can see RAM usage in megabytes, instead of kilobytes, by passing the -m switch to the free command:

Code:
# free -m
To get an idea of what is using your CPU time and RAM, you can click Home » Server Status » Daily Process Log. This is documented here:

Welcome to the cPanel & WHM documentation home. - Documentation - cPanel Documentation
 
Last edited:

JaredR.

Well-Known Member
Feb 25, 2010
1,834
22
143
Houston, TX
cPanel Access Level
Root Administrator
Friendly Moderator Note

I edited the title of this thread to make it a little easier to find in a forum search, as this discussion is definitely something that other users can benefit from. It is a frequent source of confusion to new Linux users, and I thank you for asking about it.
 
  • Like
Reactions: BottyZ