Author Topic: Swap file concerns..  (Read 3297 times)

0 Members and 1 Guest are viewing this topic.

Offline Wraithguard

  • Jr. Member
  • **
  • Posts: 10
  • Karma: 0
  • Gender: Male
  • I've just joined!
    • View Profile
    • Awards
Swap file concerns..
« on: June 29, 2010, 02:12:09 pm »
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.
If at first you don't succeed, then sky diving isn't for you.

Offline shtromm

  • Jr. Member
  • **
  • Posts: 55
  • Karma: 2
  • I've just joined!
    • View Profile
    • IT Consultants - IT consultant specialised in Free Software
    • Awards
Re: Swap file concerns..
« Reply #1 on: June 29, 2010, 02:22:51 pm »
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

Offline Wraithguard

  • Jr. Member
  • **
  • Posts: 10
  • Karma: 0
  • Gender: Male
  • I've just joined!
    • View Profile
    • Awards
Re: Swap file concerns..
« Reply #2 on: June 29, 2010, 02:29:20 pm »
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...???
If at first you don't succeed, then sky diving isn't for you.

Offline shtromm

  • Jr. Member
  • **
  • Posts: 55
  • Karma: 2
  • I've just joined!
    • View Profile
    • IT Consultants - IT consultant specialised in Free Software
    • Awards
Re: Swap file concerns..
« Reply #3 on: June 29, 2010, 03:52:47 pm »
Because - it is only used if you would use more than 2GB of RAM (in your case).
« Last Edit: June 29, 2010, 03:54:20 pm by shtromm »

Offline Wraithguard

  • Jr. Member
  • **
  • Posts: 10
  • Karma: 0
  • Gender: Male
  • I've just joined!
    • View Profile
    • Awards
Re: Swap file concerns..
« Reply #4 on: June 29, 2010, 04:17:13 pm »
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.
If at first you don't succeed, then sky diving isn't for you.

Offline Mad Penguin

  • Administrator
  • Hero Member
  • *****
  • Posts: 1422
  • Karma: 10018
  • Gender: Male
    • View Profile
    • Linux in the UK
    • Awards
Re: Swap file concerns..
« Reply #5 on: June 29, 2010, 04:18:54 pm »
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 ..)

Try;
Code: [Select]
cat /proc/sys/vm/swappiness

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

To change it, as root do;

Code: [Select]
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".


Offline Wraithguard

  • Jr. Member
  • **
  • Posts: 10
  • Karma: 0
  • Gender: Male
  • I've just joined!
    • View Profile
    • Awards
Re: Swap file concerns..
« Reply #6 on: June 29, 2010, 04:49:54 pm »
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"
If at first you don't succeed, then sky diving isn't for you.

Offline Mad Penguin

  • Administrator
  • Hero Member
  • *****
  • Posts: 1422
  • Karma: 10018
  • Gender: Male
    • View Profile
    • Linux in the UK
    • Awards
Re: Swap file concerns..
« Reply #7 on: June 29, 2010, 05:03:36 pm »
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 ...

Offline Wraithguard

  • Jr. Member
  • **
  • Posts: 10
  • Karma: 0
  • Gender: Male
  • I've just joined!
    • View Profile
    • Awards
Re: Swap file concerns..
« Reply #8 on: June 29, 2010, 07:27:56 pm »
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.
If at first you don't succeed, then sky diving isn't for you.

Offline Mad Penguin

  • Administrator
  • Hero Member
  • *****
  • Posts: 1422
  • Karma: 10018
  • Gender: Male
    • View Profile
    • Linux in the UK
    • Awards
Re: Swap file concerns..
« Reply #9 on: June 29, 2010, 08:12:06 pm »
Unlikely, what does free say?

Offline shtromm

  • Jr. Member
  • **
  • Posts: 55
  • Karma: 2
  • I've just joined!
    • View Profile
    • IT Consultants - IT consultant specialised in Free Software
    • Awards
Re: Swap file concerns..
« Reply #10 on: July 01, 2010, 05:47:34 am »
Unlikely, what does free say?


or
Code: [Select]
top

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.

http://en.wikipedia.org/wiki/Megabyte

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal