Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a VPS with VPSnoc and it is exhibiting some strange behaviour. When I total the %MEM column from a "ps faux" I get around 23%, but when I run free I get 419580/524288 = 80% used. That's a lot of RAM to be being used by non-processes, way more than on any other box I administer, or even my friend's VPS with the same provider.

I've emailed the VPSnoc support a couple of times now, but they don't even seem to be able to understand that this is a very weird thing to have happening on a system.

I wouldn't complain, except that I occasionally get out of memory errors (like when I try to set apache2 workers to >7 threads or >8 simultaneous connections) and those are just not nice.

Is there any way this could be a configuration problem that I could fix/work around, or any way this could be normal? I'm losing hope that VPSnoc will even acknowledge the problem.

They use OpenVZ, if that helps.

Edit: I have tweaked some MySQL settings, and that made what ps reported for it's RAM usage go from 7% to 4%, but the amount of RAM use reported by free dropped about 20%. I'm not longer getting out-of-memory errors, but would still like to understand the reporting better. The current output of free -m is:

             total       used       free     shared    buffers     cached
Mem:           512        320        191          0          0          0
-/+ buffers/cache:        320        191
Swap:            0          0          0

I understand better now the buffers/cache differences that can exist, but none are being shown by this output (or ever were being shown on this box) and that shouldn't cause actual out-of-memory errors.

share|improve this question
add comment

4 Answers

See http://www.linuxatemyram.com/ for an explanation of what free displays.

Do you have swap enabled?

(Edit) and please post the complete output of free.

share|improve this answer
    
If he's getting out of memory errors, this isn't the issue. –  Viaken Aug 19 '10 at 21:39
    
If there is a large discrepancy between free and the sum from ps, I guess that my link explains this discrepancy. This still means the system can run out of ram if there is no swap enabled, ie. when you set up PHP with a large maximal RAM and your web apps really use all this. There are only 400M in the instance, so maybe it's just not enough for what's happening on the machine. –  SvW Aug 19 '10 at 22:01
add comment

I use this script to get more information about memory usage: http://www.pixelbeat.org/scripts/ps_mem.py

share|improve this answer
add comment

When you run free, the output of the "used" column includes buffers and caches, which is normal for a Linux box to utilize. Linux has one of the most advanced memory managers out there, so it tries to take advantage of "free" memory to help the slower parts of your system, like your disks. Check this output:

# free
             total       used       free     shared    buffers     cached
Mem:       1048576     924824     123752          0     102444     481004
-/+ buffers/cache:     341376     707200
Swap:      2096472          0    2096472

From here, it looks like the system is consuming 88% of memory, but about 52% of it is OS cache and another 11% are buffers. It takes some getting used to, but Linux tries it's best to make use of "free" memory.

share|improve this answer
add comment
up vote 0 down vote accepted

After tons of debugging and fighting with my host, I am almost certain that this is just a bug either with OpenVZ or with the way they use it. It seems that the %MEM in ps is showing % of actual physical RAM, whereas free is showing my the amount of my allocated VPS RAM I have free.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.