Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a linux VPS which has 256 MB of memory (free only finds 248 though). However it seems I still have 85 MB free, but it's swapping for 255 MB. Why is this?

free -m

              total       used       free     shared    buffers     cached
Mem:           248        245          3          0         41         40
-/+ buffers/cache:        163         85
Swap:         1971        255       1716
share|improve this question

1 Answer 1

up vote 3 down vote accepted

You have 3MB free, not 85MB. Since you have 255MB of swap used and only 88MB of memory that could potentially be used to hold data that had been swapped, the kernel has no choice but to swap at least 167MB. The reason it has swapped more than that is that the kernel judged that performance would be better if it used that memory for a disk cache (technically, for page caching) rather than using it to hold application data that hadn't been recently accessed.

The reason 3MB are kept free is to handle bursts of load in contexts where memory can't easily be made free or re-purposed. For example, if there's a burst of network traffic or when disk I/O completes.

share|improve this answer
1  
As for why you have 3 instead of 85, Linux deems the cache more valuable than the application pages for system performance, so it doesn't attempt to load them from swap. –  Ignacio Vazquez-Abrams Jul 1 '12 at 1:09

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.