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.

First of all, I know how Linux uses memory for disk caching (http://www.linuxatemyram.com/), but this seems to be something different.

First of all, I run htop. The total memory usage %s of all running processes equals just above 50%, and the same result is shown when I add up the real memory usage of all of the running processes. However, htop lists my memory usage as 1381/1536MB.

Looking around, I found that I should check free -m, to see if some of my memory was being used for disk caching. Alas, free just displays this:

             total       used       free     shared    buffers     cached
Mem:          1536       1381        154          0          0          0
-/+ buffers/cache:       1381        154
Swap:            0          0          0

I'm now very confused. Where is all this extra memory going? Did Linux "eat my RAM"?

EDIT: Sorry for causing some confusion, this VPS is running on OpenVZ.

share|improve this question
    
I'm confused too - this is very, very odd. What distro? What are you running on this box? –  symcbean Mar 21 '11 at 9:48
    
What is your VPS provider? –  sciurus Mar 21 '11 at 16:31
    
Hello! I'm using CleverKite (cleverkite.com), and it seems as because they provide an OpenVZ-based VPS, there is no swap space provided or even allowed. I'm still not sure how this explains the disappearing RAM, though. –  Jonathan Chan Mar 21 '11 at 21:59
    
So, did you have more ram than 1536? Sorry, but I see the swap at 0 and I believed you refer at this. –  Sacx Mar 22 '11 at 6:05
    
My fault for not clarifying the question. When I add up the amount of physical memory used by each process, I find a number significantly less than 1536MB (my total amount of physical memory). However, my total memory usage is listed as near the total amount of physical memory (1381/1536MB). What I'm referring to is the disparity between these two numbers. Thanks. –  Jonathan Chan Mar 22 '11 at 6:27

1 Answer 1

Your swap is disabled. If you really configured a swap partition then use

swapon -a

to enable it. If you forgot to create a swap partition then probably you should create it and activate it.

dd if=/dev/zero of=/swap bs=1M count=1024

Where 1024 is how much swap memory do you want. For a desktop system I recommend you to use double of your ram. Now you should "format" the swap file.

mkswap /swap

Now you should enable it:

swapon /swap

Now run free -m and you should see the free swap.

If you want swap to be enabled at boot time add the following line in /etc/fstab

/swap       none    swap    sw      0       0

If you still have free disk then configure a swap partition and rerun my instruction from mkswap and change /swap with the id of the partition.

share|improve this answer
    
Please note that there is nothing at all that motivates the rule that swap should be 2x ram on Linux. If you have a lot of ram you typically need less swap space, not more. For hibernation your Swap file needs to be at-least as large as the ram however. –  pehrs Mar 21 '11 at 8:46
    
This answer doesn't seem to have anything to do with the question. –  sciurus Mar 21 '11 at 16:30
    
Note that if you follow this advice and your VM is using OpenVZ (which it smells like it is, from the lack of buffers) there's an excellent chance you will render your VM unbootable. –  nickgrim Mar 21 '11 at 18:36
    
I'm sorry for not clarifying that the VPS used OpenVZ in my original question - it has been edited to say so. I now realize that the VPS has no swap space allotted to it, but am still curious as to how this resolves the numbers. Could someone please clarify on that aspect? –  Jonathan Chan Mar 21 '11 at 22:07

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.