Page 1 of 6 123 ... LastLast
Results 1 to 10 of 51

Thread: Is SWAP really needed?

  1. #1
    Join Date
    Oct 2011
    Location
    Canada
    Beans
    951
    Distro
    Ubuntu 12.04 Precise Pangolin

    Exclamation Is SWAP really needed?

    Hey guys, I am gearing up for the release of 12.04 where I will be nuking my 32 bit 11.10 install and going with a copy of Precise x64. Anyway, when I setup this partition, I specifically disabled any SWAP space on purpose before really understand what it does. While I kinda understand it better now, I still see it like the Windows paging file and would argue that letting my system use RAM (I have plenty, 8GB) is MUCH quicker than forcing it to use my HDDs....Anyone care to disagree and explain why?



    Even when I am doing "heavy" stuff under Ubuntu, I rarely exceed 1GB/8GB usage and never notice slow downs. It's why I am inclined to disable SWAP space for 12.04 as well.
    613websites.com Canadian Web Design and Hosting

  2. #2
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Re: Is SWAP really needed?

    You're not forcing it to do anything...swap is more of a backup plan for when you run out of memory...I think it's a good idea to have about a GB, but opinions differ. Make your own mind up, unless you have a pitiful amount of RAM, you probably won't notice anyway.

  3. #3
    Join Date
    Oct 2011
    Location
    Canada
    Beans
    951
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Is SWAP really needed?

    Quote Originally Posted by MG&TL View Post
    You're not forcing it to do anything...swap is more of a backup plan for when you run out of memory.
    From what I've understood though, it doesn't just use it when it runs out of RAM though, no? Someone previously asked how much swap they should use for Ubuntu partition and they also had 8GB of ram, and someone told them 8.5GB...Is it possible even to use that much RAM under Ubuntu?

    I am also pretty sure that as long as any space is allocating for swap, the system will use it, regardless of if RAM is maxed out or not...
    613websites.com Canadian Web Design and Hosting

  4. #4
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Re: Is SWAP really needed?

    It will use a little, yes, and I'm not entirely sure why. But it will definitely not use ALL of it, probably only a tiny percentage.

  5. #5
    Join Date
    Dec 2007
    Location
    California
    Beans
    4,954
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Is SWAP really needed?

    Ram unused by applications will get used as file cache, if your box is doing a lot of file operations and unused application data is sitting in ram, sometimes it will opt to swap out that application data for more file cache, and yes file cache WILL fill up your ram, quickly.

    That's about it to my knowledge, swap is good to have (with out it your system will crash if it ever did run out of ram, memory leaks do happen)
    Last edited by jerome1232; March 17th, 2012 at 02:42 AM.
    "You can't expect to hold supreme executive power just because some watery tart lobbed a sword at you"

    "Don't let your mind wander -- it's too little to be let out alone."

  6. #6
    Join Date
    Jun 2011
    Beans
    61
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Is SWAP really needed?

    I think this ought to explain it to you the best:

    Just turn off swap (by setting swappiness to zero), restart your system, and try to use it. You will notice it will be slower. Then go set swappiness back to the previous setting and restart. Now it feels faster. See?

  7. #7
    Join Date
    Jul 2008
    Beans
    2,825

    Re: Is SWAP really needed?

    For what I do my swap is only used well I suspend. Every user can and maybe different.

  8. #8
    Join Date
    Jul 2008
    Location
    The Left Coast of the USA
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: Is SWAP really needed?

    Actually, Haneef, swappiness may or may not make much difference with as much memory as people have now. A DBA probably needs to tune it. Or someone administering servers. With 8GB on a run of the mill desktop, I don't suspect that memory will be aggressively moved to swap because there will probably be no need. When we were all trying to run 17 applications on 256MB it was different. The kernel doesn't have to worry so much about the competition for memory (well, not as much.) any more.

    A memory leak that would gobble 8GB before you caught it would be a real issue and would probably take leaking by design. I've done that for demonstration purposes. But leaks do happen when people are forgetful, I suppose.

    Swap is necessary if you want to suspend to disk. 1.1 - 1.25x memory is sufficient. All you need is enough to maintain what is held in memory. Back when memory was at a premium we used to say 2x memory so you could preserve both the memory state and what was already in swap.

    With memory as plentiful as it is, many people simply don't use a swap and suspend to RAM when they need to. If you have 16GB of memory and only ever use 5 - 10% of it, why waste the space on a partition that is of no ther use?
    Last edited by QIII; March 17th, 2012 at 03:28 AM.
    Please read The Forum Rules and The Forum Posting Guidelines
    My Blog
    A thing discovered and kept to oneself must be discovered time and again by others. A thing discovered and shared with others need be discovered only the once.
    This universe is crazy. I'm going back to my own.

  9. #9
    Join Date
    Oct 2011
    Location
    Canada
    Beans
    951
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Is SWAP really needed?

    I was hoping for a more technical explanation but;

    a) I never suspend my system (and yes, this wouldn't work well without swap space, just like my Windows 7 partition wouldn't suspend nicely because of no paging file)

    b) I noticed better performance under Windows 7 without the paging file, and it is proven you will too if you have 4GB+ RAM.

    Anyway, I will be poking around for linux literature on swap vs non-swap performance but my guess is that my eyes don't deceive me, and disabling swap = better performance (as long as your RAM is faster than your HDD, which is most likely the case).
    613websites.com Canadian Web Design and Hosting

  10. #10
    Join Date
    Jul 2008
    Location
    The Left Coast of the USA
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: Is SWAP really needed?

    Five or six years ago this was a real bone of contention.

    My feeling is this:

    For a desktop, it can't hurt but it will probably never be used.

    For a server or a machine that hosts a large database, you'd better.
    Please read The Forum Rules and The Forum Posting Guidelines
    My Blog
    A thing discovered and kept to oneself must be discovered time and again by others. A thing discovered and shared with others need be discovered only the once.
    This universe is crazy. I'm going back to my own.

Page 1 of 6 123 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •