Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a 512MB Xen VPS with 1024MB Swap.

When I SSH into it and type "free -m", it shows I have around 50MB free memory.

I had recently downgraded from a 1024MB plan because I didn't need the memory.

Since doing that, my VPS has seemed a bit sluggish, though it hasn't used all it's memory.

Is it still accessing Swap or something? "free -m" says 0 under "used" for the Swap.

share|improve this question
Please edit your question and post the full output of $ free -m. – EEAA May 12 '12 at 1:02
up vote 7 down vote accepted

For the most part, memory management for Xen guests is no different than if you were running on bare metal. You're using swap when the various tools (free -m, cat /proc/meminfo, etc.) tell you you are. In your case, your system is not using swap.

It sounds like you probably need to read Linux Ate My RAM! to brush up on the basics of how the linux kernel uses your system memory.

You really don't want un-used memory on your system - it's a waste of money. The kernel will use un-allocated pages for disk read cache, which greatly improves the IO performance of your system.

With regards to the "sluggish" feel of your system, that could be caused by a multitude of things, all of which would require you to gather data (IOps, IO latency, IOwait, load average, CPU load, etc.) over time. To ease this process, I'd highly suggest that you install a monitoring package like Munin. Munin excels at this sort of thing, and is very easy to set up.

share|improve this answer
Thanks! If I have 0 memory free, but have some used in the buffers/cache, will it start using the memory in buffers/cache or go straight to Swap? – Dav May 12 '12 at 1:17
Read that page I linked to - it's explained very well. – EEAA May 12 '12 at 1:17
Oh snap, nice! That page is amazing. – Dav May 12 '12 at 1:19
:) You're welcome. – EEAA May 12 '12 at 1:20
Could the reason it seems sluggish be there is less free memory being used for buffers/cache? – Dav May 12 '12 at 1:21

I think you misunderstood what the memory statistics were telling you. Your system is keeping 50MB free because it needs 50MB free. Free memory is needed to handle things like network traffic and disk interrupts. For more typical cases, the system just moves memory directly from one use to another. Keeping more memory free than necessary is a waste, since free memory is forever wasted.

If you decided you could make do with less memory because 50MB or so was free, then your reasoning was faulty. All the free memory was telling you was how much memory the system needed to keep free. In typical cases, it's completely unrelated to load and system memory demand.

Now that you have less memory, you still need about the same amount free. And presumably your applications are still demanding about the same amount of memory. So every MB of memory you have removed is one less MB that remains for use as a page cache. That's most likely what's responsible for the decreased performance.

share|improve this answer
Hm... that's very contradictory to what others have told me. – Dav May 12 '12 at 4:07
What did others tell you that contradicts what I said? – David Schwartz May 12 '12 at 16:03
By the way, the command sysctl vm.min_free_kbytes will tell you how many KB the system believes it needs to keep free. You can tune this value, and for low-memory systems, it's usually safe to reduce it by 30% or so. Keeping less memory free means more memory can be used, improving performance. The risk is that the system may not have enough free memory to cope with a large burst of disk or network load. (But the default is conservatively high. So lowering it is usually safe.) – David Schwartz May 12 '12 at 17:21
I ran "sysctl vm.min_free_kbytes" and it said 2879, which is 2.8MB – Dav May 12 '12 at 20:16
If you have significantly more free memory than vm.min_free_kbytes, that indicates that memory is free because the system couldn't find a way to use it. That's common at system startup, since not much data has been read from disk yet. And it's common when a process with a lot of memory usage terminates, because the system hasn't found a new use for that memory yet. If you consistently see a lot more free memory than the minimum, that indicates your system has a lot of 'churn', that is memory that is being released. – David Schwartz May 13 '12 at 3:15

What does top tell you?

From one of my hosts.

Mem:   2074768k total,  2014116k used,    60652k free,    14276k buffers
Swap:  2097144k total,      104k used,  2097040k free,  1853092k cached

Xen is offered from a few different vendors, but try and have a look in the management interface if you can't get the hypervisor to tell you exactly how much memory the guest uses?

share|improve this answer
When I use "top", it says 0k used. – Dav May 12 '12 at 1:06

Your Answer


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.