Swap file concerns..

Hi guys now i’m still using Lucid Lynx and as normal (for me anyways) i have under memory/CPU heavy loads, and noticed i have a 4612MB swap file which is not being used, surely the kernel should be using this??? Instead of using my ram… another thing i’ve noticed is that i have 2gig of ram and my swap file is twice the size surely they should be equal in size or am i missing something… Even after disabling compiz and all other none important programs the memory load still sits idle at 500 - 600meg. I know this is an issue with Lucid at present and i should follow Mad Penguins advice and reinstall karmic, but i just can’t let this go its bugging me…

Cheers WG.

  1. The swap is normally created via the installation process of a size of twice the RAM - therefore your figures seems to be reasonable.

  2. The swap is on the HDD - so each read/write access takes a few ms; the access to RAM is in the region of ns - in other word in by the factor 10^6 slower. Therefore it is in respect of performance reasonable for the Kernel first to use the RAM and if there no further heap to allocate than using the swap

All this i understand what i’m really interested in is why its not being used and my ram load is still climbing now touching 800meg and i’m only running swiftfox…???

Because - it is only used if you would use more than 2GB of RAM (in your case).

After further searching and a little research i’ve got full understanding of the Swap files thanks guys you’ve been great… but i’m still stuck as to the huge memory usage… its just a huge drain on resources when there’s literally nothing running.

Swap space is effectively overflow for your memory and typically it will only store memory that’s been allocated but is not in use. If you run your memory down to a level where not all running programs can keep themselves and the memory they need ‘most’ of the time in RAM, you really will know about it and typically your machine will start to grind to a halt.

The reason you need lots of swap (these days) is that applications, X based applications in particular, tend to leak memory. Sometimes directly and sometimes indirectly into the X server itself. (Firefox is a prime culprit) If the memory leaks are ‘direct’ you can generally recover this memory by restarting the application, but if it leaks into X, you’ll need to log out and in again - which can be inconvenient if you are “doing” things.

However, leaked memory generally does nothing, so it will happily swap out without affecting performance, hence you can sometimes see swap usage in the Gb range, but actually all the system has done it swap out leaked memory, so there are no ill effects.

You will find there is a kernel parameter called “swappiness”, which controls the kernel’s affinity for swapping … the higher this number, the more aggressively the kernel will swap stuff out, move this number to zero and it will only swap as an alternative to OOMing on you. (I set my KVM hosts to zero because if a KVM host starts to swap , the virtual machines tend to get very upset in terms of performance …)


cat /proc/sys/vm/swappiness

It will probably say “60” , which is the norm for desktops.

To change it, as root do;

echo [value in the 0-100 range] > /proc/sys/vm/swappiness

If you want to change it / see how it affects your system … generally this is not going to cause any damage as such, but I’d recommend staying away from “0” and “100”.

Mad Penguin you come to my aid yet again thank you (i bow) my swappiness is set at 10 anyway but it makes very little difference, i’m currently looking into “X” specificaly X server as it seems through out every forum i’ve searched it seems to be an nVidia issue although not seeing how this effects me as my current card has its own 1gig ram. I will post anything i find for future reference.

Wraithguard. “Lucid will be better than Vista”

Mmm, you don’t have access to the memory on the card, that’s just for it’s own internal mapping / calculations … will have zero effect on swap / X memory usage …

My bad guys a friend of mine has just pointed out theres a computational error somewhere, as HTOP is showing 2012mb total memory and Conky is showing 1.96gb something somewhere is a miss! Not sure about anyone else, but i’m using 2GB Corsair Xtreme RAM Dual Channel so now i’m wondering if its a (rare) hardware incompatability.

Unlikely, what does free say?



BTW: There is a long running confusion in respect of KB, MB, GB, etc. One definition defines

1KB = 10^3 B; 1 MB = 10^6 B, etc.

Whilst an other one, coming from the software site uses

1K = 1024 B = 2^10 B; 1 MB = 2^10 KB = 2^20 B = 1’048’576 B; etc.