2

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.

7
  • I'm confused too - this is very, very odd. What distro? What are you running on this box? Commented Mar 21, 2011 at 9:48
  • What is your VPS provider? Commented Mar 21, 2011 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. Commented Mar 21, 2011 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. Commented Mar 22, 2011 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. Commented Mar 22, 2011 at 6:27

1 Answer 1

3

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.

4
  • 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. Commented Mar 21, 2011 at 8:46
  • This answer doesn't seem to have anything to do with the question. Commented Mar 21, 2011 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. Commented Mar 21, 2011 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? Commented Mar 21, 2011 at 22:07

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.