• motruck@lemmy.zip
    link
    fedilink
    arrow-up
    1
    ·
    7 days ago

    Swap is there an emergency relief for when a runaway process starts to eat all the resources. The system gets slow the user says hey what’s that? They look and see oh wow this one process is really eating a lot of resources that’s bad, can I kill it or do I need to gracefully try to shut it down. Swap buys you time when it could matter. When you don’t have swap OOM killer takes out whatever it wants and for a desktop user that may not be that big of a deal but for a server the database is likely the first target that is taken out.

    • nullptr@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      7 days ago

      you misunderstand the meme (of course it doesn’t help either); because the alternative isn’t “no swap”, but rather “use a swap file instead of swap partition”

      • motruck@lemmy.zip
        link
        fedilink
        arrow-up
        1
        ·
        2 days ago

        Hrmm. How does that change the SSD problem if you are using a file on the SSD? I reread the meme. Maybe I’m too blurry eyed still but I don’t see that coming through.

  • bdonvr@thelemmy.club
    link
    fedilink
    arrow-up
    1
    ·
    7 days ago

    I basically never used swap until I used some script that was supposed to de-duplicate text messages from SMS backups.

    Turns out feeding it a 100,000 message archive spanning back 15 years will somehow eat up ~80GB of RAM. I doubt it should, I guess it probably just wasn’t optimized for such a large amount.

    So I made a 64GB swap file and it completed fine.

    • cannedtuna@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      9 days ago

      Shit did I botch it? I made this on my phone and the toot I copied the script from was just text. Wanted to make it look more interesting so I found this site that let you make the windows. I just went with what I thought looked best.

  • Mwa@thelemmy.club
    link
    fedilink
    English
    arrow-up
    1
    ·
    8 days ago

    SWAP RAM is useful for hibernation mode and fall back ram incase you have low memory.

    • SirLeToet@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      7 days ago

      Also for when you, for whatever reason, run out of physical memory.

      Who here worries torturing their SSDs? Those things will last lifetimes compared to HDD’s of the past (or present).

  • 87Six@lemmy.zip
    link
    fedilink
    arrow-up
    1
    ·
    9 days ago

    All I know is that I had 16GB RAM and 4GB swap and I used to get crashes sometimes.

    Set that fucker to 32GB out of spite, now no crashes. No idea why that helped. But I guess I do have like 15 tabs open on the regular (web dev)

      • tal@lemmy.today
        link
        fedilink
        English
        arrow-up
        0
        ·
        9 days ago

        I don’t recall that, but IIRC it does need to be a minimum of installed RAM if you want to be able to hibernate, since then you write out the contents of your memory to swap. That makes having at least as much swap as RAM a good rule of thumb for many systems.

        IIRC kernel crash dumps also make use of swap in a similar way, though I assume that in most sane scenarios, it’s not going to actually require as much swap as physical memory, because you won’t have all of your physical memory allocated to the kernel.

        On non-exotic Linux systems, I always make sure to have more swap than physical RAM.

        • rumschlumpel@feddit.org
          link
          fedilink
          arrow-up
          0
          ·
          9 days ago

          I don’t recall that, but IIRC it does need to be a minimum of installed RAM if you want to be able to hibernate, since then you write out the contents of your memory to swap.

          IF RAM used + swap used don’t exceed total swap space. Yeah, sometimes I run into that. Usually solved by killing webbrowsers, which suggests that most of the swap space is filled with unused webpages…

        • j3tt@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          8 days ago

          I use 1.5-2x the swap on new installations these days. I want hibernate to always work.

    • JasonDJ@lemmy.zip
      link
      fedilink
      English
      arrow-up
      0
      ·
      9 days ago

      15 tabs? Those are rookie numbers. Unless you mean “before 8:07 Monday morning”.

    • treadful@lemmy.zip
      link
      fedilink
      English
      arrow-up
      0
      ·
      9 days ago

      But I guess I do have like 15 tabs open on the regular (web dev)

      Minor league shit.

    • cannedtuna@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      9 days ago

      Used a website to make the windows since I was on mobile. Thought it looked too plain w/o the window decorations, but yeah. I mean there’s so many distros and themes, who’s to say it couldn’t be Linux. I’ve seen KDE reskinned to look like OSX

      • alecsargent@lemmy.zip
        link
        fedilink
        arrow-up
        0
        ·
        9 days ago

        It’s fine, I really like MacOS X too. To be fair those window decorations looks real nice as demos.

  • rem26_art@fedia.io
    link
    fedilink
    arrow-up
    1
    ·
    9 days ago

    Building a PC in 2026 be like “I cant afford RAM, but I can use a whole TB hard disk I shucked from an old WD external as swap and maybe my PC will feel modern”

  • Zenorbi@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    9 days ago

    I used to be this guy. We have huge amount of memory in our storage server. Why would we need swap? Well, once the system started killing programs I read up on swap and how the system handles its caches, especially ZFS ARC.

    Short version is that while the system can evict its caches syncronously, it can only async notify ZFS that it should also shrink its caches, but the out-of-memory killer will start killing before ZFS and its kernel counterpart can start to free up memory.

    A tiny bit of swap completely solved this, since swapping is sync for the kernel and the OOM killer will wait for it.

    • Fizz@lemmy.nz
      link
      fedilink
      arrow-up
      0
      ·
      9 days ago

      As well as oom situations, swapping allows the memory to be used more effectively by swapping out anonymous pages that aren’t likely to be used but can’t be dropped.

    • grrgyle@slrpnk.net
      link
      fedilink
      arrow-up
      0
      ·
      8 days ago

      I found that with swap the applications would slow to a crawl and then basically lock up entirely until I hauled my ass over and manually power cycled the machine.

  • OwOarchist@pawb.social
    link
    fedilink
    English
    arrow-up
    0
    ·
    9 days ago

    Yes, swap partitions are shit.

    The real hotness is swap drives.

    Just the use that your old 64GB SSDs were waiting for!

    (Fun fact: in Linux, if you have multiple swap partitions mounted, the kernel will automatically use striping (like RAID) in order to read and write from them as fast as possible. If you have multiple small SSDs used for swap, the read/write speed from swap can actually become pretty fast.)

      • OwOarchist@pawb.social
        link
        fedilink
        English
        arrow-up
        0
        ·
        8 days ago

        You’re going to run into issues with your motherboard’s SATA or NVME (or PCIE) controller throughput well before you get close to actual RAM speeds.

        Once you reach that bottleneck, the speed won’t increase anymore when you add more drives. The motherboard architecture just doesn’t support accessing any kind of storage device at that speed.

      • Axolotl@feddit.it
        link
        fedilink
        arrow-up
        0
        ·
        8 days ago

        I did a (very) quick search and they should just sum up, so for example a raid of 2 sata SSD with 64gb that can reach 500MB/s will have a total speed of 1GB/s,
        DDR3 ram can get up to 17GB/s so we would need 34 drives to get DDR3 speeds (not very fast BUT you would be the person with most ““RAM”” in the city without being a data center)

  • mazzilius_marsti@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    8 days ago

    unfortunately with S0ix being forced on all modern laptops, zram is the only logical choice. With s3 sleep at least i can say i need swap because i need hibernation…With S0ix? Dont bother.

  • Jul@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    0
    ·
    9 days ago

    There are good use cases for swap. I work with very performance sensitive memory hogging applications that tend to process in bursts as incoming batched data arrives. We also have a lot of required background “security” applications.

    Having the idle applications move out to swap so that a significant amount of free RAM to allow for the active, real-time applications to expand into is a major boon. RAM is expensive now, so it’s become even more critical to not waste it.

    But even in self-hosting at home I take advantage of it since I have a limited number of servers with limited RAM and a bunch of applications and/or docker containers running, many of which don’t need to be active at all times, but if they were all active, would have trouble with the limited RAM. Swap allows for inactive applications to free up RAM for the active ones and leave enough available at all times to allow an application to quickly spin up new jobs.

    Anyway, sure, for a simple desktop computer without a bunch of junk background applications running for “security” or whatever, and an overabundance of RAM installed, it’s probably not useful. But for high performance, memory hungry applications with lots of background stuff running, it can be a big help.

    That said, there are use cases where the opposite is useful and using a RAM drive is better than writing to disk for cache and temporary logs when you have enough RAM. My opnsense router for instance uses a RAM drive to store cache and logs (logs are mirrored to the NAS for long term storage, so just the local copy is lost on reboot). That system has enough RAM and I’d rather reduce disk wear, and I don’t plan to add too many other applications to that server that it would run low.

    • Kangae_Hishiryo@scribe.disroot.org
      link
      fedilink
      arrow-up
      0
      ·
      9 days ago

      Actually, there are more than these. For example, hibernation and/or hybrid suspension. It’s, AFAIK, mandatory to have a swap partition to be able to hibernate and/or hybrid suspend your device.

    • Supercrunchy@programming.dev
      link
      fedilink
      arrow-up
      0
      ·
      9 days ago

      I also found it useful to do some one-off batch processing of a big file without thinking of chunking and doing too complicated things. Imagine something like a 60GB file in a custom format that need to be deduplicated. It’s easier to just load it all up in memory and do run the algorithm 2-3x slower using a 50GB swapfile than spend hours to complicate the algorithm.

      • OwOarchist@pawb.social
        link
        fedilink
        English
        arrow-up
        0
        ·
        9 days ago

        Yep. That’s why it can be nice to just have like an old 1TB drive completely used for swap. Things might get slow once it exceeds your physical memory, but at least it will eventually finish successfully – no out of memory crashes here!

    • mexicancartel@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      0
      ·
      7 days ago

      If you(or your distro) use zram then the zram usage may also count as swap in resource monitors. For me this was the case when i saw swap usage where it is clearly not needed to swap. You can check it with swapon commands.

      Other reason is that more frequently accesed files may be cached to ram and less important stuff gets swapped. But if you notice swap being used while total ram usage including cached is much lower than total, then its probably zram(and it does write to disk so dont worry about that)

    • droans@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      8 days ago

      Because you just taught your computer how to be lazy. “oH lOoK aT mE i’M sWaP mEmOrY”

    • Brkdncr@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      8 days ago

      Saving ram to swap can be done with minimal impact. Helpful when you run out of memory and that 2gb app idling can be dumped right away instead of waiting for it to be copied to swap.

      • WhyJiffie@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        0
        ·
        8 days ago

        but that’s not what’s happening. processes do actually get removed from RAM, and when they are needed they are very slow until they are loaded back. the system thinks it’s more valuable to have that memory be filesystem cache

  • Blue_Morpho@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    9 days ago

    “Unresizeable block device at end of disk”

    Classically the swap partition was located at the physical middle of the drive so that on average, no matter where the heads where, the swap partition wasn’t far away

    • InnerScientist@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      8 days ago

      Also “unresizeable” as if you can’t just swapoff and just delete and recreated it anywhere (update the path in fstab) and then swapon again.

  • RustyNova@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    8 days ago

    I don’t really need swap until I need to compile blender… Need somewhere around 64Gb (with compression) to deal with the peaks