Can you have too much swap?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
12
down vote

favorite
1












I was just wondering if you can have a swap partition that is too big. If yes, when is a swap partition too big? What are the downsides/ill-effects of having a swap partition that's too big (even if I have plenty of disk space)?



If no, what are the benefits of having more than the recommended swap space?










share|improve this question



















  • 5




    The apparent downside is that you waste disk space. OTOH: if you have "too much" swap (say 30GB on a 4GB system), then misbehaving apps will get an out-of-memory far later and that will slow down your system. Orderly behaving apps (without memory leaks) will simply not use it. (I admit, this is a simplified view.)
    – PerlDuck
    Mar 18 at 15:45










  • I agree with @PerlDuck - "too much swap" just uses disc space. You system will be slow if it starts using swap , in that case either run less apps, lighter weight apps, or get more RAM
    – Panther
    Mar 18 at 15:49










  • I know, so if you have enough RAM, other then using too much diskspace are there any downsides ? Except offcourse "misbehaving" apps as PerlDuck said.
    – An0n
    Mar 18 at 15:50







  • 1




    VTD All the questions in the Edit justifies changing close reason from duplicate to off topic as too broad. OP is obviously miffed but meta or a chat room is a better place for discussion.
    – WinEunuuchs2Unix
    Mar 24 at 2:35







  • 3




    In case people are unsure of what @PerlDuck (and Panther) are talking about, note that even if you had effectively unlimited disk space, having more space to swap to will make processes that ought to just be terminated, and which otherwise would be swiftly terminated automatically, slow the system down to a crawl for a long time first. PerlDuck's comment would, I think, also work as an answer. If we end up reopening this question, perhaps an answer can be added about the drawbacks of having far more swap than necessary. Because there are drawbacks.
    – Eliah Kagan
    Mar 26 at 13:04















up vote
12
down vote

favorite
1












I was just wondering if you can have a swap partition that is too big. If yes, when is a swap partition too big? What are the downsides/ill-effects of having a swap partition that's too big (even if I have plenty of disk space)?



If no, what are the benefits of having more than the recommended swap space?










share|improve this question



















  • 5




    The apparent downside is that you waste disk space. OTOH: if you have "too much" swap (say 30GB on a 4GB system), then misbehaving apps will get an out-of-memory far later and that will slow down your system. Orderly behaving apps (without memory leaks) will simply not use it. (I admit, this is a simplified view.)
    – PerlDuck
    Mar 18 at 15:45










  • I agree with @PerlDuck - "too much swap" just uses disc space. You system will be slow if it starts using swap , in that case either run less apps, lighter weight apps, or get more RAM
    – Panther
    Mar 18 at 15:49










  • I know, so if you have enough RAM, other then using too much diskspace are there any downsides ? Except offcourse "misbehaving" apps as PerlDuck said.
    – An0n
    Mar 18 at 15:50







  • 1




    VTD All the questions in the Edit justifies changing close reason from duplicate to off topic as too broad. OP is obviously miffed but meta or a chat room is a better place for discussion.
    – WinEunuuchs2Unix
    Mar 24 at 2:35







  • 3




    In case people are unsure of what @PerlDuck (and Panther) are talking about, note that even if you had effectively unlimited disk space, having more space to swap to will make processes that ought to just be terminated, and which otherwise would be swiftly terminated automatically, slow the system down to a crawl for a long time first. PerlDuck's comment would, I think, also work as an answer. If we end up reopening this question, perhaps an answer can be added about the drawbacks of having far more swap than necessary. Because there are drawbacks.
    – Eliah Kagan
    Mar 26 at 13:04













up vote
12
down vote

favorite
1









up vote
12
down vote

favorite
1






1





I was just wondering if you can have a swap partition that is too big. If yes, when is a swap partition too big? What are the downsides/ill-effects of having a swap partition that's too big (even if I have plenty of disk space)?



If no, what are the benefits of having more than the recommended swap space?










share|improve this question















I was just wondering if you can have a swap partition that is too big. If yes, when is a swap partition too big? What are the downsides/ill-effects of having a swap partition that's too big (even if I have plenty of disk space)?



If no, what are the benefits of having more than the recommended swap space?







16.04 partitioning ram swap disk-usage






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 12:30









Zanna

48.1k13120228




48.1k13120228










asked Mar 18 at 15:39









An0n

80418




80418







  • 5




    The apparent downside is that you waste disk space. OTOH: if you have "too much" swap (say 30GB on a 4GB system), then misbehaving apps will get an out-of-memory far later and that will slow down your system. Orderly behaving apps (without memory leaks) will simply not use it. (I admit, this is a simplified view.)
    – PerlDuck
    Mar 18 at 15:45










  • I agree with @PerlDuck - "too much swap" just uses disc space. You system will be slow if it starts using swap , in that case either run less apps, lighter weight apps, or get more RAM
    – Panther
    Mar 18 at 15:49










  • I know, so if you have enough RAM, other then using too much diskspace are there any downsides ? Except offcourse "misbehaving" apps as PerlDuck said.
    – An0n
    Mar 18 at 15:50







  • 1




    VTD All the questions in the Edit justifies changing close reason from duplicate to off topic as too broad. OP is obviously miffed but meta or a chat room is a better place for discussion.
    – WinEunuuchs2Unix
    Mar 24 at 2:35







  • 3




    In case people are unsure of what @PerlDuck (and Panther) are talking about, note that even if you had effectively unlimited disk space, having more space to swap to will make processes that ought to just be terminated, and which otherwise would be swiftly terminated automatically, slow the system down to a crawl for a long time first. PerlDuck's comment would, I think, also work as an answer. If we end up reopening this question, perhaps an answer can be added about the drawbacks of having far more swap than necessary. Because there are drawbacks.
    – Eliah Kagan
    Mar 26 at 13:04













  • 5




    The apparent downside is that you waste disk space. OTOH: if you have "too much" swap (say 30GB on a 4GB system), then misbehaving apps will get an out-of-memory far later and that will slow down your system. Orderly behaving apps (without memory leaks) will simply not use it. (I admit, this is a simplified view.)
    – PerlDuck
    Mar 18 at 15:45










  • I agree with @PerlDuck - "too much swap" just uses disc space. You system will be slow if it starts using swap , in that case either run less apps, lighter weight apps, or get more RAM
    – Panther
    Mar 18 at 15:49










  • I know, so if you have enough RAM, other then using too much diskspace are there any downsides ? Except offcourse "misbehaving" apps as PerlDuck said.
    – An0n
    Mar 18 at 15:50







  • 1




    VTD All the questions in the Edit justifies changing close reason from duplicate to off topic as too broad. OP is obviously miffed but meta or a chat room is a better place for discussion.
    – WinEunuuchs2Unix
    Mar 24 at 2:35







  • 3




    In case people are unsure of what @PerlDuck (and Panther) are talking about, note that even if you had effectively unlimited disk space, having more space to swap to will make processes that ought to just be terminated, and which otherwise would be swiftly terminated automatically, slow the system down to a crawl for a long time first. PerlDuck's comment would, I think, also work as an answer. If we end up reopening this question, perhaps an answer can be added about the drawbacks of having far more swap than necessary. Because there are drawbacks.
    – Eliah Kagan
    Mar 26 at 13:04








5




5




The apparent downside is that you waste disk space. OTOH: if you have "too much" swap (say 30GB on a 4GB system), then misbehaving apps will get an out-of-memory far later and that will slow down your system. Orderly behaving apps (without memory leaks) will simply not use it. (I admit, this is a simplified view.)
– PerlDuck
Mar 18 at 15:45




The apparent downside is that you waste disk space. OTOH: if you have "too much" swap (say 30GB on a 4GB system), then misbehaving apps will get an out-of-memory far later and that will slow down your system. Orderly behaving apps (without memory leaks) will simply not use it. (I admit, this is a simplified view.)
– PerlDuck
Mar 18 at 15:45












I agree with @PerlDuck - "too much swap" just uses disc space. You system will be slow if it starts using swap , in that case either run less apps, lighter weight apps, or get more RAM
– Panther
Mar 18 at 15:49




I agree with @PerlDuck - "too much swap" just uses disc space. You system will be slow if it starts using swap , in that case either run less apps, lighter weight apps, or get more RAM
– Panther
Mar 18 at 15:49












I know, so if you have enough RAM, other then using too much diskspace are there any downsides ? Except offcourse "misbehaving" apps as PerlDuck said.
– An0n
Mar 18 at 15:50





I know, so if you have enough RAM, other then using too much diskspace are there any downsides ? Except offcourse "misbehaving" apps as PerlDuck said.
– An0n
Mar 18 at 15:50





1




1




VTD All the questions in the Edit justifies changing close reason from duplicate to off topic as too broad. OP is obviously miffed but meta or a chat room is a better place for discussion.
– WinEunuuchs2Unix
Mar 24 at 2:35





VTD All the questions in the Edit justifies changing close reason from duplicate to off topic as too broad. OP is obviously miffed but meta or a chat room is a better place for discussion.
– WinEunuuchs2Unix
Mar 24 at 2:35





3




3




In case people are unsure of what @PerlDuck (and Panther) are talking about, note that even if you had effectively unlimited disk space, having more space to swap to will make processes that ought to just be terminated, and which otherwise would be swiftly terminated automatically, slow the system down to a crawl for a long time first. PerlDuck's comment would, I think, also work as an answer. If we end up reopening this question, perhaps an answer can be added about the drawbacks of having far more swap than necessary. Because there are drawbacks.
– Eliah Kagan
Mar 26 at 13:04





In case people are unsure of what @PerlDuck (and Panther) are talking about, note that even if you had effectively unlimited disk space, having more space to swap to will make processes that ought to just be terminated, and which otherwise would be swiftly terminated automatically, slow the system down to a crawl for a long time first. PerlDuck's comment would, I think, also work as an answer. If we end up reopening this question, perhaps an answer can be added about the drawbacks of having far more swap than necessary. Because there are drawbacks.
– Eliah Kagan
Mar 26 at 13:04











6 Answers
6






active

oldest

votes

















up vote
5
down vote













No



At first glance you cannot have too much swap because you can see swap
as a way to increase RAM. Actually it doesn't increase RAM, it just
pretends to: If you have 8 GB of real RAM and a swap space of, say, 24
GB configured, then your programs can allocate and use up to 8+24=32 GB
of memory which sounds good at first.



But



If you run applications that either have memory leaks or aren't really
made for running with 8 GB of memory (think of video editing, for
example), then these applications will start to use that swap space,
and swap is slow. The more swap space is actively in use by these
applications, the more the system is busy with just moving memory around
to and from the disk. This will drastically slow down the overall system's
responsiveness and lead to a bad user experience.



Eventually -- when swap space is exhausted -- some applications
will face an out-of-memory situation and be killed by the kernel's
OOM_Killer.



From wiki:




The typical OOM case in modern computers happens when the operating
system is unable to create any more virtual memory, because all of
its potential backing devices have been filled.




Conclusion



Hence, one drawback of having too much swap space is: the more you
have, the later this OOM situation occurs and the longer you will have
to suffer from a lagging and unresponsive system.



Another apparent downside of course is wasting disk space but that might
not be so important nowadays.






share|improve this answer




















  • +1 for the consideration of the edge case. Personally, I'm not a big swap fan as hibernation is for bears and my systems are kept far too busy for that. ;-) Cheers.
    – Elder Geek
    Apr 8 at 16:05










  • @ElderGeek LOL. Actually Eliah Kagan made me turn my simple comment into an answer. He convinced me that the aforementioned downside of having too much swap is a crucial thing and might be important to others. I'm with you and have little swap configured (2GB with 8GB RAM) and it almost never gets touched.
    – PerlDuck
    Apr 8 at 16:23










  • I have had similar results with similar settings, I wish the 2x swap rumor would finally die.
    – Elder Geek
    Apr 10 at 20:08

















up vote
4
down vote













You won't feel any other downsides other than less space on your disk, I think that nowadays the conception of 2x the amount of ram is outdated in the majority of systems. I usually recommend to use the same size of your ram for swap memory in laptops though in order to give you the opportunity to hibernate your pc without losing any data due to the volatile nature of RAM.



The only cases where I would consider using more than 1x the size of RAM for the swap partition is when you think you are going to upgrade your RAM size in a short time. Or if you plan to use a system where you will store in a sort of cache the amount of memory used by programs not used at the very same moment.



Hope my point was clear enough, and I repeat I don't think you will experience any problem for having too much swap memory.



Have a nice day!






share|improve this answer


















  • 2




    I do not use swap at all if RAM > 2-4 Gb on a single user desktop.
    – Panther
    Mar 18 at 19:00






  • 1




    @Panther Why not ? And its not about how or when you use it. Its about the size and the usage.
    – An0n
    Mar 19 at 23:01






  • 2




    Have you considered the impact of memory leaks?
    – Elder Geek
    Apr 8 at 16:13










  • @ElderGeek Hi, no i did not consider it. I like your answer, i didn't know about memory leaks problem!
    – zurg
    Apr 10 at 17:02

















up vote
4
down vote













There’s no direct drawback to large swap space. With the way it is managed by the kernel an increase of the amount of swap space above what is sufficient has no or a negligible impact on performance.



The only downside of “too much” swap space is that you can’t use that space for storage.






share|improve this answer


















  • 1




    @An0n: I think it would be a pretty big downside to allocate all the ~6 TB currently connected to my machine as swap space. Where would I put all my music…?
    – David Foerster
    Mar 19 at 22:25






  • 2




    @An0n: What good is a computer if all it can do is boot and then not store any useful data? That sounds more like an expensive space heater.
    – David Foerster
    Mar 19 at 22:30







  • 1




    @An0n: Sure, I assumed as much but you're missing the point. I think we can agree that to be useful a computer must be able to reach a usable system state (incl. being able to boot) and have access to storage that the user can use for her personal data. That requires that it be not occupied by swap space.
    – David Foerster
    Mar 19 at 22:40







  • 2




    Of course it's relative. Just like "too much" is relative. If I have a bootable system and I allocate all my free space as swap space then it's no longer useful to me because of the lack of free space until I change its system configuration in a way that ends in more free space. In that sense the swap space would be "too much" during that time renders the system useless during that time. Anyway, I'm not here to argue semantics of words with you.
    – David Foerster
    Mar 19 at 23:26






  • 1




    @An0n To underline the point here, swap space is space you can't use for anything else. Disk storage space costs money. If your disk space is limited (mine is only 32GB), you want to keep as much of it as possible free to install programs and write files with your stuff in them, like music. People generally try to keep swap to a minimum for that reason, and no other reason. Swap is something the system might need to keep running efficiently, that is otherwise of no value to the user. In general, we want our system to use only the necessary resources, and leave us plenty to play with.
    – Zanna
    Mar 24 at 15:48


















up vote
1
down vote













What is SWAP:



Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.



Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.



Swap should equal 2x physical RAM.




Advantages:



Provides overflow space when your memory fills up completely
Can move rarely-needed items away from your high-speed memory
Allows you to hibernate



Disadvantages:



Takes up space on your hard drive as SWAP partitions do not resize dynamically
Can increase wear and tear to your hard drive
Does not necessarily improve performance (see below)




When SWAP Partitions "Don’t Help" as in "not worthy comparing to extra storage" :



If your Harddrive has only 5400 RPM and you have little RAM lets say > 2GB.
Why ? Because the system constantly wanted to access the SWAP partition, it will eventually become very slow. Even though you now have space in the memory, everything in the SWAP partition need to be moved back over. Because the system will go slow, allot stays in the SWAP partition. This can only be fixed with a reboot. Which will take a while anyway because the system need to remove everything from the SWAP partition before shutting down.




**Conclussion: **



If you would like to be able to hibernate your computer, then you should have a SWAP partition. The size of this partition should be the size of your installed memory, plus an additional 10-25% to leave room for any items that were already moved over into the SWAP partition.



If you just want a small performance boost (and you have at least a 7200rpm hard drive), then you can add a SWAP partition if you want, but it’s not needed unless you have less than 4GB of installed memory. The size of this can be whatever you’d like. However I recommend 2x the RAM as a pinpoint. IF you have enoug storage space.



If you have a 5400rpm hard drive, then you shouldn’t create a SWAP partition simply because the bottleneck will make your computer worse off. However, if you absolutely want to have SWAP, then you can still create a partition using the same sizing guidelines outlined above – but change the swappiness value to something much lower.





My OPINION:



However in any case if you use Ubuntu as your Main OS for daily use I recommend 2x the size of the RAM. Because you don't install Ubuntu just because you have a old computer. But because you want to use the system as your Main OS.



Rather buy some extra hardware if needed instead of adjusting the system partitions to keep it running.
If you buy a game you also make sure your system is "up to date" instead of adjusting the settings to make it "Playable".



You can better have some extra space, SWAP, speed, power instead of having too short or need to resize everything later on. Because you need SWAP or space, bought RAM? Or need to buy ram fast because one memory slot or stick broke.






share|improve this answer



























    up vote
    1
    down vote













    How much SWAP does hibernation really need?



    It's a misconception that you need RAM x 2 for SWAP size when you use hibernation. The swap size needs to be the size of used RAM not Installed RAM. Generally swap size needs to be 2/5th of installed RAM. To find out the bare-minimum amount of RAM needed for use:



    $ cat /sys/power/image_size
    3153907712


    On this 8 GB RAM machine 3 GB minimum is needed to hibernate.



    You can tweak the values in image_size for a smaller swap size with risk of failure. You can tweak it for a larger swap size and possibly speeding up the hibernation speed.



    Reference: https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate




    16 MB RAM in 1995, different rules for 16 GB RAM in 2018



    In the days when you had 16 MB Ram, x 2 for 32 MB swap on your 720 MB hard drive made sense. A little RAM and HDD history in this 1995 Washington Post article.



    23 years later some technical articles from that 1995 (although I didn't find any) might be found to mislead new users. I did however find a 2007 article recommending SWAP = RAM x 2.



    Back in 1995 32 MB Swap out of 760 MB HDD was 4% of HDD. Indeed the swap partition may have been used a lot in 1995. Today in 2018, 16 GB RAM x 2 for 32 GB SWAP on your 256 GB SSD doesn't make the same sense as it is taking 13% of SSD. Today my 8 GB SWAP partition isn't being used at all unless I force it to fill it up when testing OOM-Killer: Google Chrome will take up my memory to the point where it causes my computer to freeze to a near halt. What can I do to prevent this?.






    share|improve this answer






















    • +1 for pointing out the misconception of the often touted 2x rule which is total bunk.
      – Elder Geek
      Apr 8 at 16:09










    • @ElderGeek Thank you. I added a history section on when 16 MB RAM times 2 for 32 MB SWAP may have made sense.
      – WinEunuuchs2Unix
      Apr 8 at 17:22

















    up vote
    0
    down vote













    There is an overhead, indeed, but is very small; for every on-disk "page" there's a reference counter, and there's a couple of structs associated with every swap area; this is in kernel memory, so can't be paged. It's between 2 and 16 MB every 4 GB, depending on the architecture. The rest is fairly dynamic, thus dependant on usage.



    So you can have plenty, but keep in mind the paged address space itself imposes some overhead on the RAM, and on top of that there's some tracking going on for swapped pages, so it doesn't scale very far, filesystems are far more efficient than large swap areas when it comes to handling larger areas as the vfs can offload structural information to disk (normally page tables can't be swapped, because of hardware limitations).



    I can't think of any other downside, OTOH having too little swap can cause fragmentation which means more seeking. When having a lot, after certain point there will be no improvements either.



    Swapping is generally a last resource (hibernation aside), so you'll probably not benefit from having more than RAM if you have over 4GB, and sometimes even as big as RAM is too much (think 64 GB).






    share|improve this answer






















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "89"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1017021%2fcan-you-have-too-much-swap%23new-answer', 'question_page');

      );

      Post as a guest






























      6 Answers
      6






      active

      oldest

      votes








      6 Answers
      6






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      5
      down vote













      No



      At first glance you cannot have too much swap because you can see swap
      as a way to increase RAM. Actually it doesn't increase RAM, it just
      pretends to: If you have 8 GB of real RAM and a swap space of, say, 24
      GB configured, then your programs can allocate and use up to 8+24=32 GB
      of memory which sounds good at first.



      But



      If you run applications that either have memory leaks or aren't really
      made for running with 8 GB of memory (think of video editing, for
      example), then these applications will start to use that swap space,
      and swap is slow. The more swap space is actively in use by these
      applications, the more the system is busy with just moving memory around
      to and from the disk. This will drastically slow down the overall system's
      responsiveness and lead to a bad user experience.



      Eventually -- when swap space is exhausted -- some applications
      will face an out-of-memory situation and be killed by the kernel's
      OOM_Killer.



      From wiki:




      The typical OOM case in modern computers happens when the operating
      system is unable to create any more virtual memory, because all of
      its potential backing devices have been filled.




      Conclusion



      Hence, one drawback of having too much swap space is: the more you
      have, the later this OOM situation occurs and the longer you will have
      to suffer from a lagging and unresponsive system.



      Another apparent downside of course is wasting disk space but that might
      not be so important nowadays.






      share|improve this answer




















      • +1 for the consideration of the edge case. Personally, I'm not a big swap fan as hibernation is for bears and my systems are kept far too busy for that. ;-) Cheers.
        – Elder Geek
        Apr 8 at 16:05










      • @ElderGeek LOL. Actually Eliah Kagan made me turn my simple comment into an answer. He convinced me that the aforementioned downside of having too much swap is a crucial thing and might be important to others. I'm with you and have little swap configured (2GB with 8GB RAM) and it almost never gets touched.
        – PerlDuck
        Apr 8 at 16:23










      • I have had similar results with similar settings, I wish the 2x swap rumor would finally die.
        – Elder Geek
        Apr 10 at 20:08














      up vote
      5
      down vote













      No



      At first glance you cannot have too much swap because you can see swap
      as a way to increase RAM. Actually it doesn't increase RAM, it just
      pretends to: If you have 8 GB of real RAM and a swap space of, say, 24
      GB configured, then your programs can allocate and use up to 8+24=32 GB
      of memory which sounds good at first.



      But



      If you run applications that either have memory leaks or aren't really
      made for running with 8 GB of memory (think of video editing, for
      example), then these applications will start to use that swap space,
      and swap is slow. The more swap space is actively in use by these
      applications, the more the system is busy with just moving memory around
      to and from the disk. This will drastically slow down the overall system's
      responsiveness and lead to a bad user experience.



      Eventually -- when swap space is exhausted -- some applications
      will face an out-of-memory situation and be killed by the kernel's
      OOM_Killer.



      From wiki:




      The typical OOM case in modern computers happens when the operating
      system is unable to create any more virtual memory, because all of
      its potential backing devices have been filled.




      Conclusion



      Hence, one drawback of having too much swap space is: the more you
      have, the later this OOM situation occurs and the longer you will have
      to suffer from a lagging and unresponsive system.



      Another apparent downside of course is wasting disk space but that might
      not be so important nowadays.






      share|improve this answer




















      • +1 for the consideration of the edge case. Personally, I'm not a big swap fan as hibernation is for bears and my systems are kept far too busy for that. ;-) Cheers.
        – Elder Geek
        Apr 8 at 16:05










      • @ElderGeek LOL. Actually Eliah Kagan made me turn my simple comment into an answer. He convinced me that the aforementioned downside of having too much swap is a crucial thing and might be important to others. I'm with you and have little swap configured (2GB with 8GB RAM) and it almost never gets touched.
        – PerlDuck
        Apr 8 at 16:23










      • I have had similar results with similar settings, I wish the 2x swap rumor would finally die.
        – Elder Geek
        Apr 10 at 20:08












      up vote
      5
      down vote










      up vote
      5
      down vote









      No



      At first glance you cannot have too much swap because you can see swap
      as a way to increase RAM. Actually it doesn't increase RAM, it just
      pretends to: If you have 8 GB of real RAM and a swap space of, say, 24
      GB configured, then your programs can allocate and use up to 8+24=32 GB
      of memory which sounds good at first.



      But



      If you run applications that either have memory leaks or aren't really
      made for running with 8 GB of memory (think of video editing, for
      example), then these applications will start to use that swap space,
      and swap is slow. The more swap space is actively in use by these
      applications, the more the system is busy with just moving memory around
      to and from the disk. This will drastically slow down the overall system's
      responsiveness and lead to a bad user experience.



      Eventually -- when swap space is exhausted -- some applications
      will face an out-of-memory situation and be killed by the kernel's
      OOM_Killer.



      From wiki:




      The typical OOM case in modern computers happens when the operating
      system is unable to create any more virtual memory, because all of
      its potential backing devices have been filled.




      Conclusion



      Hence, one drawback of having too much swap space is: the more you
      have, the later this OOM situation occurs and the longer you will have
      to suffer from a lagging and unresponsive system.



      Another apparent downside of course is wasting disk space but that might
      not be so important nowadays.






      share|improve this answer












      No



      At first glance you cannot have too much swap because you can see swap
      as a way to increase RAM. Actually it doesn't increase RAM, it just
      pretends to: If you have 8 GB of real RAM and a swap space of, say, 24
      GB configured, then your programs can allocate and use up to 8+24=32 GB
      of memory which sounds good at first.



      But



      If you run applications that either have memory leaks or aren't really
      made for running with 8 GB of memory (think of video editing, for
      example), then these applications will start to use that swap space,
      and swap is slow. The more swap space is actively in use by these
      applications, the more the system is busy with just moving memory around
      to and from the disk. This will drastically slow down the overall system's
      responsiveness and lead to a bad user experience.



      Eventually -- when swap space is exhausted -- some applications
      will face an out-of-memory situation and be killed by the kernel's
      OOM_Killer.



      From wiki:




      The typical OOM case in modern computers happens when the operating
      system is unable to create any more virtual memory, because all of
      its potential backing devices have been filled.




      Conclusion



      Hence, one drawback of having too much swap space is: the more you
      have, the later this OOM situation occurs and the longer you will have
      to suffer from a lagging and unresponsive system.



      Another apparent downside of course is wasting disk space but that might
      not be so important nowadays.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Apr 1 at 14:46









      PerlDuck

      3,92811030




      3,92811030











      • +1 for the consideration of the edge case. Personally, I'm not a big swap fan as hibernation is for bears and my systems are kept far too busy for that. ;-) Cheers.
        – Elder Geek
        Apr 8 at 16:05










      • @ElderGeek LOL. Actually Eliah Kagan made me turn my simple comment into an answer. He convinced me that the aforementioned downside of having too much swap is a crucial thing and might be important to others. I'm with you and have little swap configured (2GB with 8GB RAM) and it almost never gets touched.
        – PerlDuck
        Apr 8 at 16:23










      • I have had similar results with similar settings, I wish the 2x swap rumor would finally die.
        – Elder Geek
        Apr 10 at 20:08
















      • +1 for the consideration of the edge case. Personally, I'm not a big swap fan as hibernation is for bears and my systems are kept far too busy for that. ;-) Cheers.
        – Elder Geek
        Apr 8 at 16:05










      • @ElderGeek LOL. Actually Eliah Kagan made me turn my simple comment into an answer. He convinced me that the aforementioned downside of having too much swap is a crucial thing and might be important to others. I'm with you and have little swap configured (2GB with 8GB RAM) and it almost never gets touched.
        – PerlDuck
        Apr 8 at 16:23










      • I have had similar results with similar settings, I wish the 2x swap rumor would finally die.
        – Elder Geek
        Apr 10 at 20:08















      +1 for the consideration of the edge case. Personally, I'm not a big swap fan as hibernation is for bears and my systems are kept far too busy for that. ;-) Cheers.
      – Elder Geek
      Apr 8 at 16:05




      +1 for the consideration of the edge case. Personally, I'm not a big swap fan as hibernation is for bears and my systems are kept far too busy for that. ;-) Cheers.
      – Elder Geek
      Apr 8 at 16:05












      @ElderGeek LOL. Actually Eliah Kagan made me turn my simple comment into an answer. He convinced me that the aforementioned downside of having too much swap is a crucial thing and might be important to others. I'm with you and have little swap configured (2GB with 8GB RAM) and it almost never gets touched.
      – PerlDuck
      Apr 8 at 16:23




      @ElderGeek LOL. Actually Eliah Kagan made me turn my simple comment into an answer. He convinced me that the aforementioned downside of having too much swap is a crucial thing and might be important to others. I'm with you and have little swap configured (2GB with 8GB RAM) and it almost never gets touched.
      – PerlDuck
      Apr 8 at 16:23












      I have had similar results with similar settings, I wish the 2x swap rumor would finally die.
      – Elder Geek
      Apr 10 at 20:08




      I have had similar results with similar settings, I wish the 2x swap rumor would finally die.
      – Elder Geek
      Apr 10 at 20:08












      up vote
      4
      down vote













      You won't feel any other downsides other than less space on your disk, I think that nowadays the conception of 2x the amount of ram is outdated in the majority of systems. I usually recommend to use the same size of your ram for swap memory in laptops though in order to give you the opportunity to hibernate your pc without losing any data due to the volatile nature of RAM.



      The only cases where I would consider using more than 1x the size of RAM for the swap partition is when you think you are going to upgrade your RAM size in a short time. Or if you plan to use a system where you will store in a sort of cache the amount of memory used by programs not used at the very same moment.



      Hope my point was clear enough, and I repeat I don't think you will experience any problem for having too much swap memory.



      Have a nice day!






      share|improve this answer


















      • 2




        I do not use swap at all if RAM > 2-4 Gb on a single user desktop.
        – Panther
        Mar 18 at 19:00






      • 1




        @Panther Why not ? And its not about how or when you use it. Its about the size and the usage.
        – An0n
        Mar 19 at 23:01






      • 2




        Have you considered the impact of memory leaks?
        – Elder Geek
        Apr 8 at 16:13










      • @ElderGeek Hi, no i did not consider it. I like your answer, i didn't know about memory leaks problem!
        – zurg
        Apr 10 at 17:02














      up vote
      4
      down vote













      You won't feel any other downsides other than less space on your disk, I think that nowadays the conception of 2x the amount of ram is outdated in the majority of systems. I usually recommend to use the same size of your ram for swap memory in laptops though in order to give you the opportunity to hibernate your pc without losing any data due to the volatile nature of RAM.



      The only cases where I would consider using more than 1x the size of RAM for the swap partition is when you think you are going to upgrade your RAM size in a short time. Or if you plan to use a system where you will store in a sort of cache the amount of memory used by programs not used at the very same moment.



      Hope my point was clear enough, and I repeat I don't think you will experience any problem for having too much swap memory.



      Have a nice day!






      share|improve this answer


















      • 2




        I do not use swap at all if RAM > 2-4 Gb on a single user desktop.
        – Panther
        Mar 18 at 19:00






      • 1




        @Panther Why not ? And its not about how or when you use it. Its about the size and the usage.
        – An0n
        Mar 19 at 23:01






      • 2




        Have you considered the impact of memory leaks?
        – Elder Geek
        Apr 8 at 16:13










      • @ElderGeek Hi, no i did not consider it. I like your answer, i didn't know about memory leaks problem!
        – zurg
        Apr 10 at 17:02












      up vote
      4
      down vote










      up vote
      4
      down vote









      You won't feel any other downsides other than less space on your disk, I think that nowadays the conception of 2x the amount of ram is outdated in the majority of systems. I usually recommend to use the same size of your ram for swap memory in laptops though in order to give you the opportunity to hibernate your pc without losing any data due to the volatile nature of RAM.



      The only cases where I would consider using more than 1x the size of RAM for the swap partition is when you think you are going to upgrade your RAM size in a short time. Or if you plan to use a system where you will store in a sort of cache the amount of memory used by programs not used at the very same moment.



      Hope my point was clear enough, and I repeat I don't think you will experience any problem for having too much swap memory.



      Have a nice day!






      share|improve this answer














      You won't feel any other downsides other than less space on your disk, I think that nowadays the conception of 2x the amount of ram is outdated in the majority of systems. I usually recommend to use the same size of your ram for swap memory in laptops though in order to give you the opportunity to hibernate your pc without losing any data due to the volatile nature of RAM.



      The only cases where I would consider using more than 1x the size of RAM for the swap partition is when you think you are going to upgrade your RAM size in a short time. Or if you plan to use a system where you will store in a sort of cache the amount of memory used by programs not used at the very same moment.



      Hope my point was clear enough, and I repeat I don't think you will experience any problem for having too much swap memory.



      Have a nice day!







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Mar 19 at 16:35









      Jeff

      428215




      428215










      answered Mar 18 at 16:01









      zurg

      646




      646







      • 2




        I do not use swap at all if RAM > 2-4 Gb on a single user desktop.
        – Panther
        Mar 18 at 19:00






      • 1




        @Panther Why not ? And its not about how or when you use it. Its about the size and the usage.
        – An0n
        Mar 19 at 23:01






      • 2




        Have you considered the impact of memory leaks?
        – Elder Geek
        Apr 8 at 16:13










      • @ElderGeek Hi, no i did not consider it. I like your answer, i didn't know about memory leaks problem!
        – zurg
        Apr 10 at 17:02












      • 2




        I do not use swap at all if RAM > 2-4 Gb on a single user desktop.
        – Panther
        Mar 18 at 19:00






      • 1




        @Panther Why not ? And its not about how or when you use it. Its about the size and the usage.
        – An0n
        Mar 19 at 23:01






      • 2




        Have you considered the impact of memory leaks?
        – Elder Geek
        Apr 8 at 16:13










      • @ElderGeek Hi, no i did not consider it. I like your answer, i didn't know about memory leaks problem!
        – zurg
        Apr 10 at 17:02







      2




      2




      I do not use swap at all if RAM > 2-4 Gb on a single user desktop.
      – Panther
      Mar 18 at 19:00




      I do not use swap at all if RAM > 2-4 Gb on a single user desktop.
      – Panther
      Mar 18 at 19:00




      1




      1




      @Panther Why not ? And its not about how or when you use it. Its about the size and the usage.
      – An0n
      Mar 19 at 23:01




      @Panther Why not ? And its not about how or when you use it. Its about the size and the usage.
      – An0n
      Mar 19 at 23:01




      2




      2




      Have you considered the impact of memory leaks?
      – Elder Geek
      Apr 8 at 16:13




      Have you considered the impact of memory leaks?
      – Elder Geek
      Apr 8 at 16:13












      @ElderGeek Hi, no i did not consider it. I like your answer, i didn't know about memory leaks problem!
      – zurg
      Apr 10 at 17:02




      @ElderGeek Hi, no i did not consider it. I like your answer, i didn't know about memory leaks problem!
      – zurg
      Apr 10 at 17:02










      up vote
      4
      down vote













      There’s no direct drawback to large swap space. With the way it is managed by the kernel an increase of the amount of swap space above what is sufficient has no or a negligible impact on performance.



      The only downside of “too much” swap space is that you can’t use that space for storage.






      share|improve this answer


















      • 1




        @An0n: I think it would be a pretty big downside to allocate all the ~6 TB currently connected to my machine as swap space. Where would I put all my music…?
        – David Foerster
        Mar 19 at 22:25






      • 2




        @An0n: What good is a computer if all it can do is boot and then not store any useful data? That sounds more like an expensive space heater.
        – David Foerster
        Mar 19 at 22:30







      • 1




        @An0n: Sure, I assumed as much but you're missing the point. I think we can agree that to be useful a computer must be able to reach a usable system state (incl. being able to boot) and have access to storage that the user can use for her personal data. That requires that it be not occupied by swap space.
        – David Foerster
        Mar 19 at 22:40







      • 2




        Of course it's relative. Just like "too much" is relative. If I have a bootable system and I allocate all my free space as swap space then it's no longer useful to me because of the lack of free space until I change its system configuration in a way that ends in more free space. In that sense the swap space would be "too much" during that time renders the system useless during that time. Anyway, I'm not here to argue semantics of words with you.
        – David Foerster
        Mar 19 at 23:26






      • 1




        @An0n To underline the point here, swap space is space you can't use for anything else. Disk storage space costs money. If your disk space is limited (mine is only 32GB), you want to keep as much of it as possible free to install programs and write files with your stuff in them, like music. People generally try to keep swap to a minimum for that reason, and no other reason. Swap is something the system might need to keep running efficiently, that is otherwise of no value to the user. In general, we want our system to use only the necessary resources, and leave us plenty to play with.
        – Zanna
        Mar 24 at 15:48















      up vote
      4
      down vote













      There’s no direct drawback to large swap space. With the way it is managed by the kernel an increase of the amount of swap space above what is sufficient has no or a negligible impact on performance.



      The only downside of “too much” swap space is that you can’t use that space for storage.






      share|improve this answer


















      • 1




        @An0n: I think it would be a pretty big downside to allocate all the ~6 TB currently connected to my machine as swap space. Where would I put all my music…?
        – David Foerster
        Mar 19 at 22:25






      • 2




        @An0n: What good is a computer if all it can do is boot and then not store any useful data? That sounds more like an expensive space heater.
        – David Foerster
        Mar 19 at 22:30







      • 1




        @An0n: Sure, I assumed as much but you're missing the point. I think we can agree that to be useful a computer must be able to reach a usable system state (incl. being able to boot) and have access to storage that the user can use for her personal data. That requires that it be not occupied by swap space.
        – David Foerster
        Mar 19 at 22:40







      • 2




        Of course it's relative. Just like "too much" is relative. If I have a bootable system and I allocate all my free space as swap space then it's no longer useful to me because of the lack of free space until I change its system configuration in a way that ends in more free space. In that sense the swap space would be "too much" during that time renders the system useless during that time. Anyway, I'm not here to argue semantics of words with you.
        – David Foerster
        Mar 19 at 23:26






      • 1




        @An0n To underline the point here, swap space is space you can't use for anything else. Disk storage space costs money. If your disk space is limited (mine is only 32GB), you want to keep as much of it as possible free to install programs and write files with your stuff in them, like music. People generally try to keep swap to a minimum for that reason, and no other reason. Swap is something the system might need to keep running efficiently, that is otherwise of no value to the user. In general, we want our system to use only the necessary resources, and leave us plenty to play with.
        – Zanna
        Mar 24 at 15:48













      up vote
      4
      down vote










      up vote
      4
      down vote









      There’s no direct drawback to large swap space. With the way it is managed by the kernel an increase of the amount of swap space above what is sufficient has no or a negligible impact on performance.



      The only downside of “too much” swap space is that you can’t use that space for storage.






      share|improve this answer














      There’s no direct drawback to large swap space. With the way it is managed by the kernel an increase of the amount of swap space above what is sufficient has no or a negligible impact on performance.



      The only downside of “too much” swap space is that you can’t use that space for storage.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Apr 9 at 16:04

























      answered Mar 19 at 16:05









      David Foerster

      26.3k1362106




      26.3k1362106







      • 1




        @An0n: I think it would be a pretty big downside to allocate all the ~6 TB currently connected to my machine as swap space. Where would I put all my music…?
        – David Foerster
        Mar 19 at 22:25






      • 2




        @An0n: What good is a computer if all it can do is boot and then not store any useful data? That sounds more like an expensive space heater.
        – David Foerster
        Mar 19 at 22:30







      • 1




        @An0n: Sure, I assumed as much but you're missing the point. I think we can agree that to be useful a computer must be able to reach a usable system state (incl. being able to boot) and have access to storage that the user can use for her personal data. That requires that it be not occupied by swap space.
        – David Foerster
        Mar 19 at 22:40







      • 2




        Of course it's relative. Just like "too much" is relative. If I have a bootable system and I allocate all my free space as swap space then it's no longer useful to me because of the lack of free space until I change its system configuration in a way that ends in more free space. In that sense the swap space would be "too much" during that time renders the system useless during that time. Anyway, I'm not here to argue semantics of words with you.
        – David Foerster
        Mar 19 at 23:26






      • 1




        @An0n To underline the point here, swap space is space you can't use for anything else. Disk storage space costs money. If your disk space is limited (mine is only 32GB), you want to keep as much of it as possible free to install programs and write files with your stuff in them, like music. People generally try to keep swap to a minimum for that reason, and no other reason. Swap is something the system might need to keep running efficiently, that is otherwise of no value to the user. In general, we want our system to use only the necessary resources, and leave us plenty to play with.
        – Zanna
        Mar 24 at 15:48













      • 1




        @An0n: I think it would be a pretty big downside to allocate all the ~6 TB currently connected to my machine as swap space. Where would I put all my music…?
        – David Foerster
        Mar 19 at 22:25






      • 2




        @An0n: What good is a computer if all it can do is boot and then not store any useful data? That sounds more like an expensive space heater.
        – David Foerster
        Mar 19 at 22:30







      • 1




        @An0n: Sure, I assumed as much but you're missing the point. I think we can agree that to be useful a computer must be able to reach a usable system state (incl. being able to boot) and have access to storage that the user can use for her personal data. That requires that it be not occupied by swap space.
        – David Foerster
        Mar 19 at 22:40







      • 2




        Of course it's relative. Just like "too much" is relative. If I have a bootable system and I allocate all my free space as swap space then it's no longer useful to me because of the lack of free space until I change its system configuration in a way that ends in more free space. In that sense the swap space would be "too much" during that time renders the system useless during that time. Anyway, I'm not here to argue semantics of words with you.
        – David Foerster
        Mar 19 at 23:26






      • 1




        @An0n To underline the point here, swap space is space you can't use for anything else. Disk storage space costs money. If your disk space is limited (mine is only 32GB), you want to keep as much of it as possible free to install programs and write files with your stuff in them, like music. People generally try to keep swap to a minimum for that reason, and no other reason. Swap is something the system might need to keep running efficiently, that is otherwise of no value to the user. In general, we want our system to use only the necessary resources, and leave us plenty to play with.
        – Zanna
        Mar 24 at 15:48








      1




      1




      @An0n: I think it would be a pretty big downside to allocate all the ~6 TB currently connected to my machine as swap space. Where would I put all my music…?
      – David Foerster
      Mar 19 at 22:25




      @An0n: I think it would be a pretty big downside to allocate all the ~6 TB currently connected to my machine as swap space. Where would I put all my music…?
      – David Foerster
      Mar 19 at 22:25




      2




      2




      @An0n: What good is a computer if all it can do is boot and then not store any useful data? That sounds more like an expensive space heater.
      – David Foerster
      Mar 19 at 22:30





      @An0n: What good is a computer if all it can do is boot and then not store any useful data? That sounds more like an expensive space heater.
      – David Foerster
      Mar 19 at 22:30





      1




      1




      @An0n: Sure, I assumed as much but you're missing the point. I think we can agree that to be useful a computer must be able to reach a usable system state (incl. being able to boot) and have access to storage that the user can use for her personal data. That requires that it be not occupied by swap space.
      – David Foerster
      Mar 19 at 22:40





      @An0n: Sure, I assumed as much but you're missing the point. I think we can agree that to be useful a computer must be able to reach a usable system state (incl. being able to boot) and have access to storage that the user can use for her personal data. That requires that it be not occupied by swap space.
      – David Foerster
      Mar 19 at 22:40





      2




      2




      Of course it's relative. Just like "too much" is relative. If I have a bootable system and I allocate all my free space as swap space then it's no longer useful to me because of the lack of free space until I change its system configuration in a way that ends in more free space. In that sense the swap space would be "too much" during that time renders the system useless during that time. Anyway, I'm not here to argue semantics of words with you.
      – David Foerster
      Mar 19 at 23:26




      Of course it's relative. Just like "too much" is relative. If I have a bootable system and I allocate all my free space as swap space then it's no longer useful to me because of the lack of free space until I change its system configuration in a way that ends in more free space. In that sense the swap space would be "too much" during that time renders the system useless during that time. Anyway, I'm not here to argue semantics of words with you.
      – David Foerster
      Mar 19 at 23:26




      1




      1




      @An0n To underline the point here, swap space is space you can't use for anything else. Disk storage space costs money. If your disk space is limited (mine is only 32GB), you want to keep as much of it as possible free to install programs and write files with your stuff in them, like music. People generally try to keep swap to a minimum for that reason, and no other reason. Swap is something the system might need to keep running efficiently, that is otherwise of no value to the user. In general, we want our system to use only the necessary resources, and leave us plenty to play with.
      – Zanna
      Mar 24 at 15:48





      @An0n To underline the point here, swap space is space you can't use for anything else. Disk storage space costs money. If your disk space is limited (mine is only 32GB), you want to keep as much of it as possible free to install programs and write files with your stuff in them, like music. People generally try to keep swap to a minimum for that reason, and no other reason. Swap is something the system might need to keep running efficiently, that is otherwise of no value to the user. In general, we want our system to use only the necessary resources, and leave us plenty to play with.
      – Zanna
      Mar 24 at 15:48











      up vote
      1
      down vote













      What is SWAP:



      Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.



      Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.



      Swap should equal 2x physical RAM.




      Advantages:



      Provides overflow space when your memory fills up completely
      Can move rarely-needed items away from your high-speed memory
      Allows you to hibernate



      Disadvantages:



      Takes up space on your hard drive as SWAP partitions do not resize dynamically
      Can increase wear and tear to your hard drive
      Does not necessarily improve performance (see below)




      When SWAP Partitions "Don’t Help" as in "not worthy comparing to extra storage" :



      If your Harddrive has only 5400 RPM and you have little RAM lets say > 2GB.
      Why ? Because the system constantly wanted to access the SWAP partition, it will eventually become very slow. Even though you now have space in the memory, everything in the SWAP partition need to be moved back over. Because the system will go slow, allot stays in the SWAP partition. This can only be fixed with a reboot. Which will take a while anyway because the system need to remove everything from the SWAP partition before shutting down.




      **Conclussion: **



      If you would like to be able to hibernate your computer, then you should have a SWAP partition. The size of this partition should be the size of your installed memory, plus an additional 10-25% to leave room for any items that were already moved over into the SWAP partition.



      If you just want a small performance boost (and you have at least a 7200rpm hard drive), then you can add a SWAP partition if you want, but it’s not needed unless you have less than 4GB of installed memory. The size of this can be whatever you’d like. However I recommend 2x the RAM as a pinpoint. IF you have enoug storage space.



      If you have a 5400rpm hard drive, then you shouldn’t create a SWAP partition simply because the bottleneck will make your computer worse off. However, if you absolutely want to have SWAP, then you can still create a partition using the same sizing guidelines outlined above – but change the swappiness value to something much lower.





      My OPINION:



      However in any case if you use Ubuntu as your Main OS for daily use I recommend 2x the size of the RAM. Because you don't install Ubuntu just because you have a old computer. But because you want to use the system as your Main OS.



      Rather buy some extra hardware if needed instead of adjusting the system partitions to keep it running.
      If you buy a game you also make sure your system is "up to date" instead of adjusting the settings to make it "Playable".



      You can better have some extra space, SWAP, speed, power instead of having too short or need to resize everything later on. Because you need SWAP or space, bought RAM? Or need to buy ram fast because one memory slot or stick broke.






      share|improve this answer
























        up vote
        1
        down vote













        What is SWAP:



        Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.



        Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.



        Swap should equal 2x physical RAM.




        Advantages:



        Provides overflow space when your memory fills up completely
        Can move rarely-needed items away from your high-speed memory
        Allows you to hibernate



        Disadvantages:



        Takes up space on your hard drive as SWAP partitions do not resize dynamically
        Can increase wear and tear to your hard drive
        Does not necessarily improve performance (see below)




        When SWAP Partitions "Don’t Help" as in "not worthy comparing to extra storage" :



        If your Harddrive has only 5400 RPM and you have little RAM lets say > 2GB.
        Why ? Because the system constantly wanted to access the SWAP partition, it will eventually become very slow. Even though you now have space in the memory, everything in the SWAP partition need to be moved back over. Because the system will go slow, allot stays in the SWAP partition. This can only be fixed with a reboot. Which will take a while anyway because the system need to remove everything from the SWAP partition before shutting down.




        **Conclussion: **



        If you would like to be able to hibernate your computer, then you should have a SWAP partition. The size of this partition should be the size of your installed memory, plus an additional 10-25% to leave room for any items that were already moved over into the SWAP partition.



        If you just want a small performance boost (and you have at least a 7200rpm hard drive), then you can add a SWAP partition if you want, but it’s not needed unless you have less than 4GB of installed memory. The size of this can be whatever you’d like. However I recommend 2x the RAM as a pinpoint. IF you have enoug storage space.



        If you have a 5400rpm hard drive, then you shouldn’t create a SWAP partition simply because the bottleneck will make your computer worse off. However, if you absolutely want to have SWAP, then you can still create a partition using the same sizing guidelines outlined above – but change the swappiness value to something much lower.





        My OPINION:



        However in any case if you use Ubuntu as your Main OS for daily use I recommend 2x the size of the RAM. Because you don't install Ubuntu just because you have a old computer. But because you want to use the system as your Main OS.



        Rather buy some extra hardware if needed instead of adjusting the system partitions to keep it running.
        If you buy a game you also make sure your system is "up to date" instead of adjusting the settings to make it "Playable".



        You can better have some extra space, SWAP, speed, power instead of having too short or need to resize everything later on. Because you need SWAP or space, bought RAM? Or need to buy ram fast because one memory slot or stick broke.






        share|improve this answer






















          up vote
          1
          down vote










          up vote
          1
          down vote









          What is SWAP:



          Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.



          Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.



          Swap should equal 2x physical RAM.




          Advantages:



          Provides overflow space when your memory fills up completely
          Can move rarely-needed items away from your high-speed memory
          Allows you to hibernate



          Disadvantages:



          Takes up space on your hard drive as SWAP partitions do not resize dynamically
          Can increase wear and tear to your hard drive
          Does not necessarily improve performance (see below)




          When SWAP Partitions "Don’t Help" as in "not worthy comparing to extra storage" :



          If your Harddrive has only 5400 RPM and you have little RAM lets say > 2GB.
          Why ? Because the system constantly wanted to access the SWAP partition, it will eventually become very slow. Even though you now have space in the memory, everything in the SWAP partition need to be moved back over. Because the system will go slow, allot stays in the SWAP partition. This can only be fixed with a reboot. Which will take a while anyway because the system need to remove everything from the SWAP partition before shutting down.




          **Conclussion: **



          If you would like to be able to hibernate your computer, then you should have a SWAP partition. The size of this partition should be the size of your installed memory, plus an additional 10-25% to leave room for any items that were already moved over into the SWAP partition.



          If you just want a small performance boost (and you have at least a 7200rpm hard drive), then you can add a SWAP partition if you want, but it’s not needed unless you have less than 4GB of installed memory. The size of this can be whatever you’d like. However I recommend 2x the RAM as a pinpoint. IF you have enoug storage space.



          If you have a 5400rpm hard drive, then you shouldn’t create a SWAP partition simply because the bottleneck will make your computer worse off. However, if you absolutely want to have SWAP, then you can still create a partition using the same sizing guidelines outlined above – but change the swappiness value to something much lower.





          My OPINION:



          However in any case if you use Ubuntu as your Main OS for daily use I recommend 2x the size of the RAM. Because you don't install Ubuntu just because you have a old computer. But because you want to use the system as your Main OS.



          Rather buy some extra hardware if needed instead of adjusting the system partitions to keep it running.
          If you buy a game you also make sure your system is "up to date" instead of adjusting the settings to make it "Playable".



          You can better have some extra space, SWAP, speed, power instead of having too short or need to resize everything later on. Because you need SWAP or space, bought RAM? Or need to buy ram fast because one memory slot or stick broke.






          share|improve this answer












          What is SWAP:



          Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.



          Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.



          Swap should equal 2x physical RAM.




          Advantages:



          Provides overflow space when your memory fills up completely
          Can move rarely-needed items away from your high-speed memory
          Allows you to hibernate



          Disadvantages:



          Takes up space on your hard drive as SWAP partitions do not resize dynamically
          Can increase wear and tear to your hard drive
          Does not necessarily improve performance (see below)




          When SWAP Partitions "Don’t Help" as in "not worthy comparing to extra storage" :



          If your Harddrive has only 5400 RPM and you have little RAM lets say > 2GB.
          Why ? Because the system constantly wanted to access the SWAP partition, it will eventually become very slow. Even though you now have space in the memory, everything in the SWAP partition need to be moved back over. Because the system will go slow, allot stays in the SWAP partition. This can only be fixed with a reboot. Which will take a while anyway because the system need to remove everything from the SWAP partition before shutting down.




          **Conclussion: **



          If you would like to be able to hibernate your computer, then you should have a SWAP partition. The size of this partition should be the size of your installed memory, plus an additional 10-25% to leave room for any items that were already moved over into the SWAP partition.



          If you just want a small performance boost (and you have at least a 7200rpm hard drive), then you can add a SWAP partition if you want, but it’s not needed unless you have less than 4GB of installed memory. The size of this can be whatever you’d like. However I recommend 2x the RAM as a pinpoint. IF you have enoug storage space.



          If you have a 5400rpm hard drive, then you shouldn’t create a SWAP partition simply because the bottleneck will make your computer worse off. However, if you absolutely want to have SWAP, then you can still create a partition using the same sizing guidelines outlined above – but change the swappiness value to something much lower.





          My OPINION:



          However in any case if you use Ubuntu as your Main OS for daily use I recommend 2x the size of the RAM. Because you don't install Ubuntu just because you have a old computer. But because you want to use the system as your Main OS.



          Rather buy some extra hardware if needed instead of adjusting the system partitions to keep it running.
          If you buy a game you also make sure your system is "up to date" instead of adjusting the settings to make it "Playable".



          You can better have some extra space, SWAP, speed, power instead of having too short or need to resize everything later on. Because you need SWAP or space, bought RAM? Or need to buy ram fast because one memory slot or stick broke.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 31 at 20:28









          An0n

          80418




          80418




















              up vote
              1
              down vote













              How much SWAP does hibernation really need?



              It's a misconception that you need RAM x 2 for SWAP size when you use hibernation. The swap size needs to be the size of used RAM not Installed RAM. Generally swap size needs to be 2/5th of installed RAM. To find out the bare-minimum amount of RAM needed for use:



              $ cat /sys/power/image_size
              3153907712


              On this 8 GB RAM machine 3 GB minimum is needed to hibernate.



              You can tweak the values in image_size for a smaller swap size with risk of failure. You can tweak it for a larger swap size and possibly speeding up the hibernation speed.



              Reference: https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate




              16 MB RAM in 1995, different rules for 16 GB RAM in 2018



              In the days when you had 16 MB Ram, x 2 for 32 MB swap on your 720 MB hard drive made sense. A little RAM and HDD history in this 1995 Washington Post article.



              23 years later some technical articles from that 1995 (although I didn't find any) might be found to mislead new users. I did however find a 2007 article recommending SWAP = RAM x 2.



              Back in 1995 32 MB Swap out of 760 MB HDD was 4% of HDD. Indeed the swap partition may have been used a lot in 1995. Today in 2018, 16 GB RAM x 2 for 32 GB SWAP on your 256 GB SSD doesn't make the same sense as it is taking 13% of SSD. Today my 8 GB SWAP partition isn't being used at all unless I force it to fill it up when testing OOM-Killer: Google Chrome will take up my memory to the point where it causes my computer to freeze to a near halt. What can I do to prevent this?.






              share|improve this answer






















              • +1 for pointing out the misconception of the often touted 2x rule which is total bunk.
                – Elder Geek
                Apr 8 at 16:09










              • @ElderGeek Thank you. I added a history section on when 16 MB RAM times 2 for 32 MB SWAP may have made sense.
                – WinEunuuchs2Unix
                Apr 8 at 17:22














              up vote
              1
              down vote













              How much SWAP does hibernation really need?



              It's a misconception that you need RAM x 2 for SWAP size when you use hibernation. The swap size needs to be the size of used RAM not Installed RAM. Generally swap size needs to be 2/5th of installed RAM. To find out the bare-minimum amount of RAM needed for use:



              $ cat /sys/power/image_size
              3153907712


              On this 8 GB RAM machine 3 GB minimum is needed to hibernate.



              You can tweak the values in image_size for a smaller swap size with risk of failure. You can tweak it for a larger swap size and possibly speeding up the hibernation speed.



              Reference: https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate




              16 MB RAM in 1995, different rules for 16 GB RAM in 2018



              In the days when you had 16 MB Ram, x 2 for 32 MB swap on your 720 MB hard drive made sense. A little RAM and HDD history in this 1995 Washington Post article.



              23 years later some technical articles from that 1995 (although I didn't find any) might be found to mislead new users. I did however find a 2007 article recommending SWAP = RAM x 2.



              Back in 1995 32 MB Swap out of 760 MB HDD was 4% of HDD. Indeed the swap partition may have been used a lot in 1995. Today in 2018, 16 GB RAM x 2 for 32 GB SWAP on your 256 GB SSD doesn't make the same sense as it is taking 13% of SSD. Today my 8 GB SWAP partition isn't being used at all unless I force it to fill it up when testing OOM-Killer: Google Chrome will take up my memory to the point where it causes my computer to freeze to a near halt. What can I do to prevent this?.






              share|improve this answer






















              • +1 for pointing out the misconception of the often touted 2x rule which is total bunk.
                – Elder Geek
                Apr 8 at 16:09










              • @ElderGeek Thank you. I added a history section on when 16 MB RAM times 2 for 32 MB SWAP may have made sense.
                – WinEunuuchs2Unix
                Apr 8 at 17:22












              up vote
              1
              down vote










              up vote
              1
              down vote









              How much SWAP does hibernation really need?



              It's a misconception that you need RAM x 2 for SWAP size when you use hibernation. The swap size needs to be the size of used RAM not Installed RAM. Generally swap size needs to be 2/5th of installed RAM. To find out the bare-minimum amount of RAM needed for use:



              $ cat /sys/power/image_size
              3153907712


              On this 8 GB RAM machine 3 GB minimum is needed to hibernate.



              You can tweak the values in image_size for a smaller swap size with risk of failure. You can tweak it for a larger swap size and possibly speeding up the hibernation speed.



              Reference: https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate




              16 MB RAM in 1995, different rules for 16 GB RAM in 2018



              In the days when you had 16 MB Ram, x 2 for 32 MB swap on your 720 MB hard drive made sense. A little RAM and HDD history in this 1995 Washington Post article.



              23 years later some technical articles from that 1995 (although I didn't find any) might be found to mislead new users. I did however find a 2007 article recommending SWAP = RAM x 2.



              Back in 1995 32 MB Swap out of 760 MB HDD was 4% of HDD. Indeed the swap partition may have been used a lot in 1995. Today in 2018, 16 GB RAM x 2 for 32 GB SWAP on your 256 GB SSD doesn't make the same sense as it is taking 13% of SSD. Today my 8 GB SWAP partition isn't being used at all unless I force it to fill it up when testing OOM-Killer: Google Chrome will take up my memory to the point where it causes my computer to freeze to a near halt. What can I do to prevent this?.






              share|improve this answer














              How much SWAP does hibernation really need?



              It's a misconception that you need RAM x 2 for SWAP size when you use hibernation. The swap size needs to be the size of used RAM not Installed RAM. Generally swap size needs to be 2/5th of installed RAM. To find out the bare-minimum amount of RAM needed for use:



              $ cat /sys/power/image_size
              3153907712


              On this 8 GB RAM machine 3 GB minimum is needed to hibernate.



              You can tweak the values in image_size for a smaller swap size with risk of failure. You can tweak it for a larger swap size and possibly speeding up the hibernation speed.



              Reference: https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate




              16 MB RAM in 1995, different rules for 16 GB RAM in 2018



              In the days when you had 16 MB Ram, x 2 for 32 MB swap on your 720 MB hard drive made sense. A little RAM and HDD history in this 1995 Washington Post article.



              23 years later some technical articles from that 1995 (although I didn't find any) might be found to mislead new users. I did however find a 2007 article recommending SWAP = RAM x 2.



              Back in 1995 32 MB Swap out of 760 MB HDD was 4% of HDD. Indeed the swap partition may have been used a lot in 1995. Today in 2018, 16 GB RAM x 2 for 32 GB SWAP on your 256 GB SSD doesn't make the same sense as it is taking 13% of SSD. Today my 8 GB SWAP partition isn't being used at all unless I force it to fill it up when testing OOM-Killer: Google Chrome will take up my memory to the point where it causes my computer to freeze to a near halt. What can I do to prevent this?.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Apr 8 at 17:20

























              answered Apr 1 at 0:53









              WinEunuuchs2Unix

              35.9k759134




              35.9k759134











              • +1 for pointing out the misconception of the often touted 2x rule which is total bunk.
                – Elder Geek
                Apr 8 at 16:09










              • @ElderGeek Thank you. I added a history section on when 16 MB RAM times 2 for 32 MB SWAP may have made sense.
                – WinEunuuchs2Unix
                Apr 8 at 17:22
















              • +1 for pointing out the misconception of the often touted 2x rule which is total bunk.
                – Elder Geek
                Apr 8 at 16:09










              • @ElderGeek Thank you. I added a history section on when 16 MB RAM times 2 for 32 MB SWAP may have made sense.
                – WinEunuuchs2Unix
                Apr 8 at 17:22















              +1 for pointing out the misconception of the often touted 2x rule which is total bunk.
              – Elder Geek
              Apr 8 at 16:09




              +1 for pointing out the misconception of the often touted 2x rule which is total bunk.
              – Elder Geek
              Apr 8 at 16:09












              @ElderGeek Thank you. I added a history section on when 16 MB RAM times 2 for 32 MB SWAP may have made sense.
              – WinEunuuchs2Unix
              Apr 8 at 17:22




              @ElderGeek Thank you. I added a history section on when 16 MB RAM times 2 for 32 MB SWAP may have made sense.
              – WinEunuuchs2Unix
              Apr 8 at 17:22










              up vote
              0
              down vote













              There is an overhead, indeed, but is very small; for every on-disk "page" there's a reference counter, and there's a couple of structs associated with every swap area; this is in kernel memory, so can't be paged. It's between 2 and 16 MB every 4 GB, depending on the architecture. The rest is fairly dynamic, thus dependant on usage.



              So you can have plenty, but keep in mind the paged address space itself imposes some overhead on the RAM, and on top of that there's some tracking going on for swapped pages, so it doesn't scale very far, filesystems are far more efficient than large swap areas when it comes to handling larger areas as the vfs can offload structural information to disk (normally page tables can't be swapped, because of hardware limitations).



              I can't think of any other downside, OTOH having too little swap can cause fragmentation which means more seeking. When having a lot, after certain point there will be no improvements either.



              Swapping is generally a last resource (hibernation aside), so you'll probably not benefit from having more than RAM if you have over 4GB, and sometimes even as big as RAM is too much (think 64 GB).






              share|improve this answer


























                up vote
                0
                down vote













                There is an overhead, indeed, but is very small; for every on-disk "page" there's a reference counter, and there's a couple of structs associated with every swap area; this is in kernel memory, so can't be paged. It's between 2 and 16 MB every 4 GB, depending on the architecture. The rest is fairly dynamic, thus dependant on usage.



                So you can have plenty, but keep in mind the paged address space itself imposes some overhead on the RAM, and on top of that there's some tracking going on for swapped pages, so it doesn't scale very far, filesystems are far more efficient than large swap areas when it comes to handling larger areas as the vfs can offload structural information to disk (normally page tables can't be swapped, because of hardware limitations).



                I can't think of any other downside, OTOH having too little swap can cause fragmentation which means more seeking. When having a lot, after certain point there will be no improvements either.



                Swapping is generally a last resource (hibernation aside), so you'll probably not benefit from having more than RAM if you have over 4GB, and sometimes even as big as RAM is too much (think 64 GB).






                share|improve this answer
























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  There is an overhead, indeed, but is very small; for every on-disk "page" there's a reference counter, and there's a couple of structs associated with every swap area; this is in kernel memory, so can't be paged. It's between 2 and 16 MB every 4 GB, depending on the architecture. The rest is fairly dynamic, thus dependant on usage.



                  So you can have plenty, but keep in mind the paged address space itself imposes some overhead on the RAM, and on top of that there's some tracking going on for swapped pages, so it doesn't scale very far, filesystems are far more efficient than large swap areas when it comes to handling larger areas as the vfs can offload structural information to disk (normally page tables can't be swapped, because of hardware limitations).



                  I can't think of any other downside, OTOH having too little swap can cause fragmentation which means more seeking. When having a lot, after certain point there will be no improvements either.



                  Swapping is generally a last resource (hibernation aside), so you'll probably not benefit from having more than RAM if you have over 4GB, and sometimes even as big as RAM is too much (think 64 GB).






                  share|improve this answer














                  There is an overhead, indeed, but is very small; for every on-disk "page" there's a reference counter, and there's a couple of structs associated with every swap area; this is in kernel memory, so can't be paged. It's between 2 and 16 MB every 4 GB, depending on the architecture. The rest is fairly dynamic, thus dependant on usage.



                  So you can have plenty, but keep in mind the paged address space itself imposes some overhead on the RAM, and on top of that there's some tracking going on for swapped pages, so it doesn't scale very far, filesystems are far more efficient than large swap areas when it comes to handling larger areas as the vfs can offload structural information to disk (normally page tables can't be swapped, because of hardware limitations).



                  I can't think of any other downside, OTOH having too little swap can cause fragmentation which means more seeking. When having a lot, after certain point there will be no improvements either.



                  Swapping is generally a last resource (hibernation aside), so you'll probably not benefit from having more than RAM if you have over 4GB, and sometimes even as big as RAM is too much (think 64 GB).







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 1 at 0:52

























                  answered Apr 1 at 0:39









                  Ismael Luceno

                  1245




                  1245



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1017021%2fcan-you-have-too-much-swap%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      GRUB: Fatal! inconsistent data read from (0x84) 0+xxxxxx

                      `kcmshell` modules relation with `/usr/share/applications`

                      How to enroll fingerprints to Ubuntu 17.10 with VFS491