Swap. What do people use these days?
Posted by heldain@reddit | linux | View on Reddit | 273 comments
I've been using Linux since the mid-90s, and it used to be a swap partition equal to memory size.
The recommendation then dropped to half your memory, once it became 'memory is cheap'.
Now generally I still create a swap partition, but only a few Gb in size.
There obviously are situations where you want a specific amount, like if you plan to use hibernation you'd want more. But...
How do people generally setup their swap these days?
cameos@reddit
I don't create swap partition or file, I always use zram swap.
thelastasslord@reddit
Why do people use zram to create a swap file in RAM when zswap is built into the kernel and enabled by default? How is it different?
G0rd0nFr33m4n@reddit
I do both, but my swap partition is on an accessory SSD.
cameos@reddit
I would avoid SSD for swap space. I even moved /tmp, /var/log, /var/cache in RAM for Linux systems that have 1GB+ RAM.
JokeJocoso@reddit
Hardware durability concerns? SSDs can endure more than some HDDs nowadays.
cameos@reddit
Still, I avoid unnecessary writings to SSD drives, plus, RAM access is much faster than SSD.
JokeJocoso@reddit
In Kernel (memory management) I Trust.
Indeed.
G0rd0nFr33m4n@reddit
Yeah, but as I said that's just a "spare" ssd I use for temporary stuff. Plus, having 16 GB of ram and zram swap enabled with high priority, that physical swap partition is very seldom touched.
blenderbender44@reddit
Isn't zram swap, just ram? How is that any different than just having no swap at all?
TomDuhamel@reddit
It's compressed ram. Basically compresses the memory that isn't in active use. Because the rate is generally quite good, this is quite effective. This again uses the assumption that ram is cheap and you have plenty — it's not a good strategy if you have little ram to begin with.
cgcmake@reddit
His point still stands. Compressed RAM isn’t what most users think of Swap. macOS compresses RAM and dynamically Swap by default, the latter referring to disk only.
funbike@reddit
Doesn't matter what "most users think". What matters is what works well. And it works very well.
cgcmake@reddit
Your system crashes when it runs out of RAM, that sure isn’t working well
LiesArentFunny@reddit
I also use zram on my desktop.
My system doesn't crash when it runs out of RAM. It slows to a halt as it spends an increasing percentage of it's time simply uncompressing and recompressing memory.
In theory maybe I could get it to crash... if I waited for like 24 hours with a workload intended to do that... in practice that doesn't happen. Given that this is a desktop that is used interactively and not a server that runs for days without me checking on it it's basically inconceivable that it will ever actually crash from lack of ram.
Berengal@reddit
Same as if it runs out of swap, so no difference there.
cgcmake@reddit
But that’s an added security
linmanfu@reddit
Except that swap can easily be added at any time to a running system. RAM can't be.
cgcmake@reddit
And it is done so automatically on macOS and Windows
Berengal@reddit
That doesn't matter if it works well.
funbike@reddit
You don't understand how it works.
CosmicDevGuy@reddit
I remember Windows 10 should've had something like that in it too, right?
blenderbender44@reddit
Ok that's an interesting idea. So if you had 32GB of ram it might make sense to compress 16GB of it?
robvdl@reddit
no, it only puts unused ram pages into swap, that is the point.
stuff that is access a lot won't get put there.
if you have 32gb of RAM then perhaps 16gb will be used as a disk cache though
vrdz@reddit
In my understanding it leads to memory compression on demand, since in practice compressed memory uses between 2 and 3 times less space. Which makes me wonder if this is any help for small memory capacities anyway.
calinet6@reddit
In my experience it helps even more with small memory capacities. As long as the CPU is reasonable for the compression/decompression.
_leeloo_7_@reddit
can you point in the direction of how to set this up?
GL4389@reddit
Just do a search on how to create/setup zram swap for the OS that you are using.
INITMalcanis@reddit
"Just do a search" is bad advice these days. Google is really terrible now.
xezo360hye@reddit
Use DuckDuckGo then. Or go directly to Arch Wiki
John_from_ne_il@reddit
Do not pass Go?
[Sorry, I had to.]
Unslaadahsil@reddit
That's your issue: you still waste your time with the ad-searcher google.
Sixcoup@reddit
That will almost always be better than asking a random guy to explain it to you on reddit in an unrelated thread.
Littux@reddit
I have the url memorized by now:
https://wiki.archlinux.org/title/zRAM
_leeloo_7_@reddit
Thank you!
Brisingr05@reddit
Depends on the distro, but the Arch wiki page should be good enough. zram-generator would be the simplest on systemd distros. Also, distros like Fedora enable it by default.
INITMalcanis@reddit
First thing to check is to see if your distro just does it anyway. Garuda does, for example.
funbike@reddit
That's what I use. It's great.
You just lose hibernate, but I don't use that anyway.
Brilliant_Fudge_8478@reddit
microstrategy is, on Prod. was lazy... highup swap and works perfectly
brunoreis93@reddit
I still use it, it's my placebo
nicman24@reddit
if it reaches the limit something needs to die so i just configure early oot
it is quite hard to fill more than 32
Maledict_YT@reddit
For my PC, I've setup a 16gb swap partition. If I don't do that, it's unusable after more than 3 tabs open.
deke28@reddit
None. I have 64Gb of RAM. This is one of the nice things about being old is I can spend money on important things like extra RAM.
xXBongSlut420Xx@reddit
you should still use swap, the memory subsystem is designed with it in mind. https://chrisdown.name/2018/01/02/in-defence-of-swap.html
Shikadi297@reddit
I don't understand some of the paragraphs in that article. I'm not saying it's wrong, just that I don't understand some of the terminology, for example
I don't understand why the chance of successful long term reclamation is low, or why that is bad, or why it can cause page thrashing. Is it that keeping things in memory contributes to memory fragmentation?
I have similar questions about almost all of the explanation paragraphs, so it doesn't make for a compelling argument. This is more like a comment to the author though who probably isn't here right now, but I have a reasonably good understanding of how paging works so I would imagine the audience that can understand exactly what is being communicated is very small, and already agrees with the article because they already understand the points
dumogin@reddit
This is bad because if a reclamation isn't long term leads to a page fault in the near future which is an expensive operation. When a page fault occurs the CPU has to retrieve data from storage which takes up a lot of clock cycles.
The probability of a successful long-term page reclamation is lower, because there are two (four if you can private and shared) types of memory mappings anonymous mappings and file mappings. File mappings map a file to memory and these pages can always be reclaimed because the data is available in storage. Anonymous mappings aren't backed by a file, they only exist in memory. If you have swap the system can swap anonymous pages and then reclaim this memory. This gives the memory manager of your OS more memory to work with. The article describes why this is an advantage.
Shikadi297@reddit
Your explanation still leaves out the same details I was asking for. If you have 64GB of ram, and you have 5GB of anon pages in memory, why does that hurt performance for other anon pages?
Why does a section of memory not being reclaimed but also not being touched lead to a page fault in the near future?
Is it possible maybe I don't understand the meaning of the word "reclaim" in this context? To my knowledge, it means the pages are no longer needed, and adding them back to the free memory pool is referred to as reclaiming. The idea that a page sitting in memory for days causes page faults somewhere else doesn't make any sense to me (and I'm not saying it's incorrect, I'm just trying to understand)
dumogin@reddit
If your memory is mostly free it doesn't really matter.
Because if it isn't accessed it could be swapped out and used for active processes (or prefetching). This way you can use the memory more efficiently.
If there are enough free pages the system doesn't have to reclaim any pages. This description of reclaim is pretty great.
Shikadi297@reddit
That kinda makes it seem like the author is incorrect then, because that description is in the medium load section. So if I have 32gb ram, and I'm typically using 12gb, it seems like I still would rather not have swap
ShumpEvenwood@reddit
I'm with you. I also found the article confusing and I'm reaching to the same conclusion as you. For example in the low/no contention case without swap:
If this is the case, we no longer have a no/low contention situation?
C0rn3j@reddit
Can people stop linking this article with zero benchmarks.
Swap is useless, completely useless, unless you need hibernation or think your system should take a little extra time before going OOM.
Source: Lack of a single objective benchmark proving "here if you don't use swap, you can see this X% decrease in this area, reproducibly"
No_Pin_4968@reddit
Yeah honestly it kinda just seem like a waste of disk space if you ask me.
I have tested with various sizes of swap on my 32 GB RAM desktop, but the swap space is almost never used. We're talking maybe a couple of kilobytes of data that might end up in swap.
I'm starting to think the only real useful application of swap is when you're operating with very weaksauce servers and very demanding applications as a sysadmin, but even then people don't want to see the performance decrease that swap introduces, so we always scale our applications back so it doesn't take all the RAM.
It mostly seems like a bad bandaid from the 90ies that still sticks around to this day. Surely people can come up with better solutions these days, now that we can fit operating system within operating systems within operating systems.
C0rn3j@reddit
Swap on anything but a modern NVMe tLC is going to run like ass, and even then it's bad.
ElasticSearch is going commit if it starts running even partially on swap...
The only good arguments for it are hibernation, "my RAM is literally soldered and I am poor", and very poor applications that either are incapable of using the storage correctly even when they don't necessarily need to load everything into memory, and poorly written applications that are hogging memory for no reason.
To both app reasons, the response is "fix the app", and stop trying to hot glue it with swap.
I am almost tempted to write up a blog post showing why swap is BAD, because that one you have real benchmarks of today, meanwhile, no resources demonstrating how swap is good for performance with an actual benchmark exist.
Batman543342@reddit
If you need to process data bigger than ram, then swap space could be useful.
No_Pin_4968@reddit
Yes, I think you should. We need to have a conversation about better solutions. If you feel confident in your knowledge of this subject, maybe you can be the voice against swap?
C0rn3j@reddit
Eh, not a badge I'd like to wear, people get mad enough when I point out you need a Pro subscription to get security updates on Ubuntu and its derivatives, and that's a much more important problem.
linmanfu@reddit
But you are assuming people have an unlimited budget to buy more RAM right? Because that's a very strong assumption that doesn't apply to most people.
C0rn3j@reddit
Yeah baby, I really am assuming that if you're running out of RAM, you have unlimited budget to afford a 10 eur 16GB stick.
linmanfu@reddit
Please explain how that works with laptops and soldered RAM.
PlasticSoul266@reddit
But RAM is not about performance, it is about your system not shitting the bed when it's full.
C0rn3j@reddit
Why don't you just run your system off your SSD then? You get much more storage for much less money!
Buy more if you use more than you have. Or setup swap if it's soldered. Already covered under "you think your system should take a little extra time before going OOM"
PlasticSoul266@reddit
I meant "SWAP* is not about performance", but okay
rich000@reddit
I'll be honest, while I get the theoretical arguments, I try to avoid having swap.
When I've used swap in the past (on 4.0+) I'd end up with situations like gcc eating up all the RAM and the system being nonresponsive for 5min before it gets killed, and maybe ZFS stops syncing until I hardware reset.
Without swap when this happens then gcc dies and otherwise nothing bad happens. Sure, oom killer could disrupt something more important, but odds are that systems will restart it at least in that case.
I don't disagree that Linux was intended to have swap, but until these pathological failure modes are fixed I'll live without it. Oh, and making more kernel APIs gpl-only isn't the failure mode I'm talking about, since I mentioned ZFS. :)
linmanfu@reddit
This is similar to my experience up until about 2021. I think Ubuntu introduced the OOM package and that stopped it.
Hamilton950B@reddit
The IO and swap bugs were around for a good ten years or more but seem to have been completely defeated in the last few years.
https://bugzilla.kernel.org/show_bug.cgi?id=196729
https://bugzilla.kernel.org/show_bug.cgi?id=12309
rich000@reddit
Very happy to hear, though that comment chain definitely makes my brain hurt. :)
NVMe may also help reduce the impact of issues as it becomes more typical.
Schlaefer@reddit
Depends on the setup, but with zram and a properly configured oom killer I don't see how this can happen today.
rich000@reddit
Neither do I, but I wasn't talking about zram.
myrsnipe@reddit
A very informative read 👍
zlice0@reddit
skimming through that still seems weird. almost every system i use has a lot of ram. for home i only use swap when doing big compiles like chrome. and for work systems even though swap is enabled, they rarely use megabytes, if any, for swap.
One_Egg_4400@reddit
Good read. Thanks, BongSlut420!
milesgloriosis@reddit
Shopping for a computer lately and the salesman asked me why I needed 64 gigs of RAM. I looked at him and said there is no substitute for cubic inches. He had no clue yeah I'm that old.
Mundane_Bus9491@reddit
I don't get it. What does it mean?
8--------D-@reddit
no one knows what it means, but it's provocative!
linmanfu@reddit
I think it's a reference to internal combustion engines, where engine sold with a higher volume of the piston should always have a higher output.
brimston3-@reddit
For a long time, the standard unit for car engine displacement was cubic inches (and not liters). To the point where there are literally songs written about engine cylinder volume referencing cu-in. displacement (eg. the Beach Boys - 409, refering to the eponymous chevorlet big-block 409 in³ V8). Large displacement engines were extremely popular for drag racing in the '60s and '70s because more volume -> more boom -> more speed.
It picked up a more ironic meaning when turbochargers and superchargers made it possible to produce smaller, lighter engines that outperformed the old, naturally aspirated big-blocks (but had their own problems like throttle lag), and because of the general weight reduction of vehicles overall, the larger, heavier engines became a liability on short strips when acceleration was king.
trucekill@reddit
I'm always curious what kind of workloads people are running on their machines. Every now and then I wish I could just throw more RAM at a problem. Like I'll be doing some 3D rendering with Blender's Geometry Nodes and I'll exceed my system's 64GB of RAM and I think about how I could make more complex models if I only had 128GB or even more RAM
thecomputerguy7@reddit
No replacement for displacement.
Unless you can figure out how to strap a turbo/supercharger to it 😏
lukasaldersley@reddit
That shouldn't be cause for replacement, that should be an addition
INITMalcanis@reddit
"I wish I didn't have all this RAM"
- No one, ever
TheNinthJhana@reddit
Lol when I compare ram usage as of today and 20 years ago then there is no way not to agree with you ! Give web browser any RAM size it will eat it :0
coolreader18@reddit
That's because of overcommit though, right? Like, a web browser will likely request the virtual address space for whatever ram is available, but that doesn't mean it's actually using that, and it can easily go to other processes if they need some.
apollo-ftw1@reddit
Only if you run windows 98 with more than 1gb of ram
INITMalcanis@reddit
In this case the OS is what you wish you didn't have
Unairworthy@reddit
Well I have 64GB of RAM AND 72GB of swap!
pppjurac@reddit
Same. all my machines are with maxed out RAM.
_greg_m_@reddit
64Gb?? That's only 8GB. 🤣🤣🤣
Not a lot for a modern computer.
Amenhiunamif@reddit
Due to b being easily confused with B it isn't used as an unit of measurement, bit are always written as bit.
lusuroculadestec@reddit
This is completely false. Memory manufactures reference module sizes in bits and just use a lower-case b all the time. The typical consumers and non-technical users just never notice it because they never look at memory at the level of individual components.
Amenhiunamif@reddit
There is no official (eg. IEEE) assignment of b as the letter for bit. If some memory manufacturers decided to do that anyways - that's good for them, but has no influence on the greater public. But because I'm curious - where can I find those references where b is used for bit all the time?
lusuroculadestec@reddit
The JEDEC standards use the lower-case b. The use of 'Mb' and 'Gb' are explicitly used when defining memory addressing as part of the standard.
Look at pretty much any datasheet for memory modules, e.g. https://www.mouser.com/datasheet/2/671/16gb_ddr5_sdram_diereva-3193781.pdf
turdas@reddit
The 961 Kbps FLAC I'm streaming for my friends over this 96 Kbps Discord stream using my 1 Gbps internet connection would like to have a word with you.
Amenhiunamif@reddit
bps is a different unit than bit. And as speeds are usually stated in bits instead of bytes confusion is avoided just as well, especially since MBps is commonly written as MB/s.
Caleb_Whitlock@reddit
Same i never think of ram with linux cause 64gb cost the same as 16gb ram for mac os amd 32gb on windows. Linux lets ur money go further
Exact-Teacher8489@reddit
Did that as well system was slow anyway because swap was full. Then did more swap and it runs great.
polarbearwithagoatee@reddit
The purpose of swap in a well-functioning modern Linux system is to free up space for the page cache. It is not there to serve as "extra memory" for when you are running low on physical memory.
There's this persistent myth that turning off swap improves performance in a system with "enough" memory, but it may well do the opposite if a program has some little-used data occupying memory that would be better utilized for increasing the size of the page cache.
If you want to avoid having a system become unresponsive due to paging when low on memory, the solution is to use something like earlyoom, not to turn off swap.
rich000@reddit
Never heard of earlyoom, but the first thing I'd want to ask is why it isn't already the default in the kernel. Pathological paging issues are probably the main reason so many admins disable swap.
polarbearwithagoatee@reddit
I always use earlyoom but can see why it might not be a good default for certain server workloads. When your active working set is larger than physical memory, the kernel only has bad options to choose from.
rich000@reddit
Right now the kernel tends to choose the worst possible option - going into an IO storm. If there is a better alternative, it should be the kernel default, or even just an option. I have no idea what earlyoom is but it sounds like it isn't in the mainstream kernel.
stCarolas@reddit
It's independent service. For example: https://fedoraproject.org/wiki/Changes/EnableEarlyoom
visor841@reddit
I can back this up, launching Windows games would frequently make my system unresponsive until I added swap. My system does a lot of caching due to the copious amounts of Firefox tabs I keep, and the memory management definitely seems to need swap in order to keep up.
Sarin10@reddit
You should try Auto-Tab Discard. Tabs are out to sleep after x minutes, so that they don't take up resources.
visor841@reddit
Something like that would've helped, but I also had other development stuff open sometimes using a bunch of RAM (yes, you can blame electron). The issue seemed to be when launching a Windows game that wanted more RAM that was currently free, things would just lock up, and I play multiple games that want 10GB+ of RAM.
Solving the issue without swap would've been a pain, adding swap solved the problem instantly and I've had no issues since.
DFS_0019287@reddit
With 64GB of RAM, I have more than enough for the page cache, even without swap. Sorry for the badly formatted output,
calinet6@reddit
Looks like a desktop; probably true. For servers and databases and other things that make far more use of page cache it could be a different conclusion.
So, no one size fits all recommendation, as usual.
DFS_0019287@reddit
Yep, for sure. It depends on your workload. I mostly do email, web browsing, development and the occasional video editing on my machine. If I were doing 3D animation, anything extremely memory-intensive, or anything that hammers the file system, my answer might change.
hellslinger@reddit
swapfile, and no zram on laptop to make hibernation easy.
Cpt-Ktw@reddit
Don't you need swap larger than your RAM in order to hibernate your PC?
If you are playing with an AI locally and happen to overflow your RAM without a swap partition your system if going to glitch the fuck out and crash.
Some applications might also expect the swap to exist and rely on it for something.
c64z86@reddit
I just use the default whatever the distro sets it up as. Right now I'm using Mageia 9 with 4GB of swap and 16GB of RAM.
_-Kr4t0s-_@reddit
Well I have 128GB of RAM so I do the opposite - I use some of my RAM as a hard drive instead.
8--------D-@reddit
that's it? I have 1tb of ram, no hard disk, no CPU, nothing else. I just sit there and stare at my pile of ram
_-Kr4t0s-_@reddit
Lol. You’d be surprised but I do actually put it to use.
crackez@reddit
12 cores, 24GB RAM, 2GB Swap.
Revenarius@reddit
Same GB of Ram size. I will not miss less of 40GB on my drive.
Hellrazor236@reddit
I have an old 256GB SATA SSD that's too small to use for any other purpose but otherwise refuses to die, so I use it for swap.
Maykey@reddit
I use x2 RAM with the main idea that if tmpfs on /tmp start eating memory, it has a chance to be swapped
headrift@reddit
No physical swap... I had that potentially burn up an early SSD and have stayed away from it this decade. At about that time I wanted to build a good future-resistant build. It ended up with 32GB RAM -- the box is now serving as my server -- the extra parts paid off eventually 👍
brightlights55@reddit
https://chrisdown.name/2018/01/02/in-defence-of-swap.html
Note Red Hat recommends 4Gb swap for memory greater than 64Gb. This was for RHEL 8 running Oracle Databases.
dsn0wman@reddit
Running database servers, and running your laptop are two very different use cases.
In my experience oom killer is going to kill your DB if you run out of swap (not great but usually recoverable). But, your database will also be pretty useless if it's memory is getting swapped in and out.
So I like to have some swap like you said 2-4GB depending on how much memory you have. And be smart about how much memory is allocated to the DB. Then you can have some time in a swappy situation to kill bad actors on your own, or get the DB down gracefully to minimize any recovery that needs to be done.
If it's your laptop, then your main considerations are all about how well you're computer sleeps, and wakes up. Because whatever oom killer is doing in a swappy situation is probably fine.
brightlights55@reddit
Fair enough - but I work in an environment where consultants were advising us to set swap at memory/2. We have servers at 512Gb ram.
dsn0wman@reddit
That's a very old style recommendation. Oracle used to ask for that as well before 11g I think.
Superb_Raccoon@reddit
It's also 6 years old.
I started on SCO UNIX and AIX 2.3... swap is rarely needed but the system expects it, so it is hand to have 4 or 8TB set aside.
barkingcorndog@reddit
u/Superb_Raccoon over here using $300 SSDs for swap.
Superb_Raccoon@reddit
I made myself laugh when I realized I put TB not GB.
FranticBronchitis@reddit
It's called a high speed disk cache!
Omniwing@reddit
I work with enterprise RHEL/Centos/Rocky systems and 4Gb swap partition is my go to. Anything else, including Zram just adds an extra layer of complexity that I don't need.
theblu3j@reddit
I use ZRAM instead, which removes disk wear and compresses as well. The stat I’ve heard is it compresses on average somewhere around 1:3, so I can fit a fuck ton of swap on my RAM if I really wanted. RAM based swap is also just going to be faster than disk based swap too. Only negative I’ve heard is that hibernation won’t work.
TheLastTreeOctopus@reddit
This may be a stupid question, but could you use ZRAM and a swap file/partition at the same time, and have your programs utilize ZRAM while the swap file/partition is used for hibernation?
oguza@reddit
Yes, you can use many swaps together, like one swap partition, a swap file and also zram. You need to set priority on those. For example, when you have a swap file and later installed zram, it comes with higher priority and kernel use zram first.
AFAIK, there is no way to separate processes per swap.
polarbearwithagoatee@reddit
zram can also be configured to write out uncompressible and/or idle pages to a separate block storage device, which should perform better than just having a second low-priority disk-based swap device.
beertown@reddit
I didn't know about that, it's super smart! But for some reason I can find documentation about this configuration. Would you mind to share a link?
polarbearwithagoatee@reddit
https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html
Take a look at the section about "writeback".
beertown@reddit
Thank you very much
TheLastTreeOctopus@reddit
Thank you! 😊
natermer@reddit
I don't do hibernation so I can't speak to that. Hibernation use is pretty rare nowadays because it has some issues that the kernel can't solve and normal sleep mode works very well.
But Zram + Disk swap works well. Use zram-generator for systemd and it'll set it up correctly for you. The defaults for the zram size can be tweaked... I like to limit it to half or 8GB of RAM. But I don't know if that is optimal. I only tweak it when I notice performance issues.
Using both as swap works because Linux supports priorities for swap. On my systems the swap file gets a -2 priority while zram gets 100. This means that disk swap will only get used if zram is used up first.
Patient_Sink@reddit
You can, but you'll have to setup a script to remove the zram swap when suspending IIRC, and recreate it when resuming. You can do the same to also only enable the actual swap when hibernating, if you don't want to use one otherwise.
linmanfu@reddit
The other negative is that it requires the CPU and its link to RAM to have spare capacity. Some computer games (city builders like Cities:Skylines, transport sims like Simutrans, and grand strategy games like Europa Universalis) are primarily limited by the PC's ability to shove as much data as possible through the CPU. If the CPU is having to compress and decompress data those games will run noticeably more slowly and the overall reduction of RAM will mean you have to play on smaller maps, use fewer assets, etc. They are often very happy to store those assets in swap though. And I don't think this is an obscure case because we are talking about one of the top 20 games on Steam.
ddyess@reddit
I see swaps as an extreme 1% solution; 99% of the time I probably don't need it, but when I do, I want to have enough. So I've learned to just match my ram and have it if I hit an extreme 1% problem. I don't know if I'll go higher than 32gb swap. It seems ridiculous, but it also seemed ridiculous to have 8, and 16gb swaps and I did use them 1% of the time.
Hot-Profession4091@reddit
Disk is cheap. I also match my RAM size. I never miss that 32GB of SSD, but that swap has saved my bacon when training models a few times.
kilgore_trout8989@reddit
Yep, RAM is cheap but so is storage. I don't miss the 32GB of storage space and its clutch for the 1-2 programs that randomly need 48 or 64GB to compile.
pharmacy_666@reddit
i just use whatever's default. my Linux computer never uses up all its memory
herd-u-liek-mudkips@reddit
Swap is not generally about getting emergency memory, it's about making memory reclamation egalitarian and efficient.
pfmiller0@reddit
But if you never use all your memory in the first place why do you need to worry about reclaiming it?
herd-u-liek-mudkips@reddit
Because outside of extremely niche circumstances, you do use all your memory. Linux will use all the "excess" RAM you have for caching, and eventually something needs to be evicted.
pfmiller0@reddit
I guess. But I have swap configured and it barely gets touched. Maybe a few hundred MB ever gets used. Doesn't seem like I'd miss it all that much if it wasn't there.
PotatoMan-404@reddit
On my home laptop I have 16GB RAM and 16GB swap which I really use 1-2 GB. But on my work laptop I have 8 GB RAM and 4 GB swap and I used 2GB+ almost every day
mykesx@reddit
Zero swap on servers or machines with 64G of RAM.
If your important server is swapping, you are royally screwed. SSH in may not succeed or can take $$$ worth of time. The server may not respond at all.
Workstation? 1x or 2x RAM, depending upon how much RAM.
I_miss_your_mommy@reddit
I don't even know why we use swap. RAM is cheap, so I'd rather buy more of that then wear out my ssd.
Brisingr05@reddit
Why do people think swap is for "extra memory"? If you don't have enough RAM, then you don't have enough RAM. No amount of swap is going to change that, because that's not its purpose.
mgedmin@reddit
Having swap means that the OS can move out currently unused dirty writable mappings to disk. Not having swap means the OS is forced to discard file-backed pages such as executable code.
When I last tried to run with no swap at all (in 2014, after upgrading to a previously unknown-to-me luxury of 8 whole gigabytes of RAM), running out of memory meant my OS would essentially freeze (slow down to 0.5 fps mouse movement at first, and then choke completely), doing disk I/O all the time, not letting me do stuff like type, switch virtual consoles, or kill offending browser tabs. Waiting for the OOM killer was fruitless (I waited 20 minutes in one occasion, according to my notes) and I learned to just Alt+SysRq+S,U,B as soon as it got into that state.
Adding swap made it so that running out of RAM made the system a bit sluggish, which prompted me to open a terminal tab, launch
htop
, notice the offending program and do something about it. Or, actually, the OOM killer would usually kill a Chrome tab or something without me even noticing a slowdown.This is why I don't try to run swapless any more.
ceene@reddit
My experience was exactly the opposite: having swap, the system started to move things around from ram to swap and viceversa and it would just completely hang for minutes. Removing all swap caused malloc errors or the OOM to kill the offending process in a matter of seconds.
NeverMindToday@reddit
Yup. Having the system slow down when you run out of physical memory rather than just randomly killing stuff or crashing is generally preferable. You get to save files, close apps, or if really necessary reboot cleanly etc.
I_miss_your_mommy@reddit
So what is it for then?
calinet6@reddit
Efficiently using the RAM you do have.
Basically, there are all kinds of allocated memory that are simply wasted, will never really be used, and would be far better off just freed but for whatever reason cannot be.
Having that stuff in RAM, even if you have a lot, is just silly. Allowing it to swap makes room for other uses of your real RAM that actually are useful and speed up your system, like the file cache.
It’s not going to make a groundbreaking difference, but it’s not useless.
Having memory that’s reserved but never going to be used in RAM, on the other hand, is useless.
Brisingr05@reddit
This blogpost by a kernel dev working on Linux memory management explains it best.
Informal_Bunch_2737@reddit
Because its literally to be used as an extension of RAM when you run low on memory?
It will take section of RAM that are from idle stuff and put it in a swap file to free up memory. The other name for a swap file is Virtual Memory.
GOKOP@reddit
Virtual memory is absolutely not another name for swap.
https://en.wikipedia.org/wiki/Virtual_memory
Informal_Bunch_2737@reddit
From your link: "is a memory management technique that provides an "idealized abstraction of the storage resources that are actually available on a given machine" which "creates the illusion to users of a very large (main) memory".
Googling shows various results (linux swap file virtual memory)
"Swap space in Linux is an extension of physical RAM, offering virtual memory that helps maintain system stability and performance. It allows processes to continue running when RAM is fully used and prevents memory errors."
"A swap file is a designated space on a hard disk drive or solid-state drive that acts as virtual memory for a computer system."
Virtual memory is something that is not memory, acting like memory.... like a swap file.
GOKOP@reddit
...are you for real? Virtual memory is a per process resource that's an abstraction over whatever physical memory you may have (or not have*), including RAM and swap. I thought the Wikipedia article makes it quite clear.
* You may sometimes notice processes in top or htop which have hundreds of gigabytes of virtual memory allocated, on Linux that's fine as long as they don't actually try to use it
NeverMindToday@reddit
I think the confusion stems from the Windows world using the term Virtual Memory to refer to pagefiles and it stuck.
But you're right - Virtual Memory is a memory addressing scheme that abstracts the fragmented layout of physical memory addresses behind a clean unified address space.
Informal_Bunch_2737@reddit
It is literally using storage space to extend the RAM. You know...the HDD. What magical hardware do you think its using to do that?
Or do you think its just an API to downloadmoreram.com?
GOKOP@reddit
You said that virtual memory is "another name of swap". It is not, as I've already literally said, it's an abstraction over any physical memory, including swap and normal RAM, and possibly other things. I've also mentioned how a process can have more physical memory allocated (though it's unusable) than both RAM and swap combined. I never said that swap isn't a part of virtual memory, I said that it's not the same thing. Learn to read.
Informal_Bunch_2737@reddit
And if you google "Is a swap file virtual memory" the answer is Yes.
GOKOP@reddit
Oh my god. You literally have an entire Wikipedia article about virtual memory, just read it properly, with understanding.
Informal_Bunch_2737@reddit
Lets just give it up.
Something can be two things at once. We're obviously just approaching this from different directions.
One_Egg_4400@reddit
It's the old "I can explain it to you, but I can't understand it for you" situation 🙃
maethor@reddit
It kinda is if you're coming from Windows, where if you want to manage the swap file you use the virtual memory settings dialog. I'm not surprised people conflate the two.
KnowZeroX@reddit
I don't see why you wouldn't use swap. If you are worried about ssd wear, just lower the swapiness. Then you get the best of both worlds
Aleix0@reddit
swap is not just extra ram
GrimThursday@reddit
You can’t think of any reasons why someone would use swap? If you extended your imagination, you can maybe conceive of people with soldered RAM in a laptop, for one
dasunsrule32@reddit
Hibernate. That's really about it.
prevenientWalk357@reddit
1 GB Swap in a zRAM drive ftw.
Gamer7928@reddit
I also use a swap partition in my Fedora install. My laptop has 16GB memory, so I have a 16GB swap partition as well.
SupFlynn@reddit
If i am setting into a 2-4gb ram pc i dont use swap anything above that i use zram swap
lowbandwidthb@reddit
I have a newer laptop with 16gb of onboard memory so I can't upgrade. I like to play Star Citizen occasionally, which can easily use 32gb of memory. I set up a 32gb swap file that only gets used for SC, then wrote a bash script that clears the swap file when I'm done playing. Other than that, it never gets used.
linmanfu@reddit
Yes, it similarly. I have a desktop with 16GB and a laptop with only 4GB. I have games that won't run on one or both unless I add some swap. I have a startup script to add a swapfile and play the game.
GarretAllyn@reddit
That sounds like a massive failure on the developers' part
Rikudou999@reddit
Swap file doesn’t make sense cuz nowadays we have a lot of ram
linmanfu@reddit
Being rich is OK. Assuming everyone is as rich as you are is not fine.
ahferroin7@reddit
For my laptop which has 32 GB of RAM I use 16 GB of swap space, largely because I actually did some testing and that was the turnover point where adding more stopped having an impact on system behavior.
For my home server, I’ve actually got 128 GB of swap space (as two 64 GB logical volumes, each on a different drive) despite the system having 64 GB of RAM, largely because I run a lot of VMs there and actually do need a significant amount of swap space to fit everything. And, again based on testing, I got better behavior letting the host manage swap and the VMs pretend like they always have the full amount of memory than any other approach I tried.
In both cases, I use zswap configured to use the z3fold allocator with LZ4HC compression (again, tested it and this got me the best behavior on both systems) and configured to auto-shrink as stuff gets swapped in.
In most cases other than extreme situations like that home server, I normally go with 4 GB as a starting point and then test scaling it up roughly 1 GB at a time until I stop seeing issues with memory handling. Usually for a client system this works out to somewhere around half of the system RAM.
colin_colout@reddit
Think about how much max memory you'll need in a worst case and allocate that.
I have 64gb ram and use a lightweight WM, so I tend to just let it be.
If think I'll need it, I can always temporarily create a swap file, but I can't see myself adding it to fstab
KamiIsHate0@reddit
I have 32gb ram setup and use 4Gb swap becos some programs refuse to work without it. Nowadays i prefer to use zram whenever possible.
R4yn35@reddit
Which progs do that? I've never come across those.
KamiIsHate0@reddit
I had a lot of problems with davinci and blender+krita running in a system without swap and adding 2gb solved allat. RPG maker MV is another that i had some issues.
Akangka@reddit
I set swap larger than the ram size, because I only got 3 GB ram. Better slowdown than literal crash.
TheAgentOfTheNine@reddit
No swap, just a lot of ram.
daemonpenguin@reddit
I have a small swap partition. 2GB of swap and 8GB of RAM. I almost never run out of RAM, or even use more than half of it, this gives me a little buffer. If the system starts to swap, I'll feel the performance hit from I/O and go looking for the problem.
OldHighway7766@reddit
I use whatever archinstall configure in my system. Won't even check it 😁
CosmicDevGuy@reddit
I use default setting which is about 2GiB, I'm kinda surprised to see it being used every now and then although last I checked 1GiB was used.
Doubt I'll need to grow it to 4GiB or more.
throwaway490215@reddit
I have a laptop with 4gb of ram and never added swap. The browser is smart enough to close it's tabs automatically and compiling/gaming isn't worth using swap for.
dismorphic@reddit
I buy enough RAM I'll never need swap. swapoff -a.
If anything I'd dd a blank file to be used as swap on a partition of a gig or two in size
I also don't hibernate, I only S3 sleep. There may be considerations for that, last time I checked the contents of RAM were written to swap then restored on the next boot. Been a long long time since I've bothered with that though so assume my info is old/outdated.
DFS_0019287@reddit
I don't use any swap on my primary workstation. But to be fair, it has 64GB of RAM.
I also don't use swap on my Raspberry Pi machines because swapping to an SD card is ridiculously slow and I try to minimize writes to the card.
On my laptop with 16GB of RAM, I have 8GB of swap. If it uses more than a couple of GB of swap, it's going to be unusable anyway, so having more swap doesn't make sense.
OptimalAnywhere6282@reddit
Twice the amount of RAM I have, because I have too little, just 4GB. I somehow got Linux to take the same amount of resources than windows, but it looks way better, even compared to macOS it has a chance.
StableMayor8684@reddit
64GB server. Went with 16GB swap partition. It went unused (for weeks), until it was used (almost all of it).
I am considering raising swap to 32GB. Even after I add another 64GB of RAM.
Bottom line, set it up. It costs nearly nothing on the disk side, and the system may end up using, as designed.
VacationAromatic6899@reddit
16GB RAM 32GB svap
deadbeef_enc0de@reddit
I just set it to 16GB which is likely overkill. If I need more swap than that something has gone horribly wrong
Super-Situation4866@reddit
Vfx production machine with 196gb of ram, and 256gb swap. SSds are cheap, my OS takes nothing and I don't store any files locally. I use tf out of swap, quite often hitting max.
Linux4ever_Leo@reddit
I still go the "equal to my memory" route.
garth54@reddit
My main machine currently have 24gb swap, and 32gb ram.
I tend to have tons of tabs open, and lots of applications running.
However, my HTPC, mythtv server & router/torrent server only have 1gb of swap each.
DoUKnowMyNamePlz@reddit
Swap. What is it good for? Absolutely nothin. Sorry, had the song war by Edwin Starr stuck in my head
6950X_Titan_X_Pascal@reddit
buy an epyc 7551 & get 64gb ddr4 x32
IfLfQV@reddit
square root of memory
henfiber@reddit
why not log2 of memory
leaflock7@reddit
swap in the past was playing a major role as dump memory to cover the needs of not having enough.
With the pass of years as memory became more available swap went to those that no matter how much memory they have they fully utilize it or they want to sleep/hybernate their pcs.
Usually I use swap as a file.
jask0000@reddit
Just use zram.
LiamBox@reddit
Depends on the machine
A steam deck is locked to 12gb of ram and found out deadlock runs better with an 8gb swap file
ayylmaonade@reddit
I always keep a 4GB partition for swap, but I use zram/zswap for compression to get a little extra mileage out of it. It's not really something I need as I've got 32GB of RAM and that's fine for my tasks, but I find it's a nice-to-have. I find that when using a swappiness value of like 10-20 in conjuction with zswap works really well.
_greg_m_@reddit
It's really astonishing that people on a Linux group can't see the different between "Gb" (gigabit) and "GB" (gigabyte) when talking about a memory size.....
TheUnreal0815@reddit
Got 64GB of Ram, 64GB of zram set up as swap And a 64GB swap partition that is rarely if ever used in practice, I mainly use it for hibernation.
I do a lot of things like compiling in zram as well, to reduce wear on my SSD.
left_shoulder_demon@reddit
64 threads, 64 GB RAM, 64 GB swap.
Usually, a few MB are used, because there are things running in the background that are less important than the page cache, but cmake will gladly start 66 parallel g++ instances, and in the right project that pushes 2-4GB of other stuff out to swap.
I could probably get away with much less swapspace, but zero would definitely be too little.
herd-u-liek-mudkips@reddit
Fedora defaults to zram up to 8 GB, so that's what I use.
sledgesloth@reddit
The battery of my laptop is dead and I move it around a lot, so Swap equal to Ram and a bit.
My understanding is that using it for hibernate is the biggest reason to have a bigger Swap size.
conquistadorespanyol@reddit
Yes, it's also my usecase. There is a world of difference between hibernate and suspend on laptops with deteriorated batteries.
sledgesloth@reddit
Yeah. Often I just gotta move a few meters and hibernate is my savior.
patrik3031@reddit
I put 32 gb on my 16gb ram system, have yet to see any swap be used.
Last-Assistant-2734@reddit
32GB RAM -> I use 1,25 * RAM
16GB -> 1,5 * RAM
8GB - > 2*RAM
In that ballpark. Hardly ever swapping though, and hibernate is anyways so-so.
azraelzjr@reddit
I use 8GB, with swappiness adjusted to less aggressive as I am on 64GB of RAM
Sigfrodi@reddit
I use swap partition and reduce swappiness.
saddas1337@reddit
I don't use swap since I have 48 GB of RAM and no HDDs, since swap kills SSD lifespan
eriomys@reddit
Linux is so fast and memory efficient that with a small ssd and 16 GB RAM I do not need any swap.
Unlikely-Sympathy626@reddit
Swap make sure there is something. Monitor it now and again to see how much used. Based on that add more ram or increase size. Really simple like that.
Only thing wrong you can do is no swap like my IT manager and wonder why if I keep telling him on a 1 vcpu system with one gig ram.
He goes oh PostgreSQL stopped working because site is down. I am like did you add a freaking swap file yet?
rklrkl64@reddit
I just put 64GB RAM in my PC and don't have any swap at all. My next PC in 2-3 years will probably have 128GB RAM and no swap again.
rklrkl64@reddit
I just put 64GB RAM in my PC and don't have any swap at all. My next PC in 2-3 years will probably have 128GB RAM and no swap again.
Groovy_bugs@reddit
I have 32 GB of RAM, but sometimes compiling different things at the same time (for work) consumes 40 GB.
Similar_Sky_8439@reddit
With such larger ram sizes, no need for swap... If u are above 8gb ram..u will find unused swap bcoz even the storage i.e. ssd are v fast
xplosm@reddit
I use hibernation in my desktops more than in the laptops but still reserve the size of the RAM in the system for swap partition.
I was seduced by using a swap file instead but it's a chore to configure for hibernation.
gioco_chess_al_cess@reddit
Starting from your comment I looked into it because I did not know the issues with configuring hibernation to swap files (I think you mean indicating the correct offset for the file for resume). It seems it is no longer needed on recent versions of systemd https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Pass_hibernate_location_to_initramfs
xplosm@reddit
Oh that’s great news! Thanks for this. It’s really easy nowadays it seems. Time to experiment!
TheMinus@reddit
Yeah, when I close the lid of my laptop, there is a huge chance it won't wake up after that. Maybe it's because I have only 2 Gb swap on 16 Gb of RAM.
HeligKo@reddit
I forgot about this use case. This is the perfect modern reason for a decent size swap partition.
San4itos@reddit
I set up a swap file because I sometimes play with image generation. But if I don't I really don't need it.
beertown@reddit
I do use a swap file (or partition) on my laptop. Just few GB.
I think that since we have SSDs, compared to mechanical harddisks, a light swap activity has an almost undetectable effect on performance, with the benefit of a better usage of RAM.
So yes, on a desktop PC swap is good. On servers, it depends on the purpose of the server.
Zram and zswap are, also, good options.
flemtone@reddit
I have a 2gb swap file just incase it's needed.
Fungled@reddit
Don’t use a swap partition anymore - much easier just to create a swap image in the root partition
pincopallinux@reddit
Same size as ram if you want hybernation or hybrid suspend to work at all. On top of that zram for performance.
EarlMarshal@reddit
I use a ram file with very low swappiness. My 128GB should be enough
zeanox@reddit
I use a 50gb swap partition.
muffinman8679@reddit
a couple megs of swap is fine, as if you never go into swap...you never never go into swap,,,,,,as ram is a lot faster then swap
twistedLucidity@reddit
A partition set to double RAM (I only have 8GBs available) as this not only gives me swap space, but it's big enough for hibernate to work (I only have a laptop).
Maybe there's a better way, but this works and I have other things to do.
PeriodicallyYours@reddit
Once I had 8G RAM, I had zram + about 10G swap in an HDD partition.
Now I have 24G RAM + 20G HDD swap which is normally never used but still low mem conditions might happen, like running two instances in Windows in VMs or raytracing a hi-res image in Blender.
SuAlfons@reddit
When I first setup my main desktop PC with Manjaro, I went with a swap file.
Then went through the Arch Wiki on the subject of Swap
Installed zRam and for good measure the dynamic swap allocation by some systems module.
After seeing 0 use of that for over a year (32GB RAM), I only checked for zRam upon reinstalling that PC with EndeavourOS. Works great since 2 years or so.
whosdr@reddit
Apparently the last few days I just haven't had any swap mounted. I have more RAM than I realistically need (64GiB installed, often using only around 10-20GiB including for VMs).
I think you can specify a partition for hibernation that isn't also mounted as swap space. I haven't looked into it enough though.
HomicidalTeddybear@reddit
If it's a laptop I make it at least as large as the memory size, simply because of its second purpose in life - suspend to disk/hibernate. non-laptop? Depends what the machine's for. For a desktop? eh, half ram probably.
mgedmin@reddit
I let the installer make decisions. The last time I used it (Ubuntu 19.04), it created a 2 GB swap file for this ThinkPad X390 with 16 GB of RAM.
At some point I installed the
swapspace
package that has a daemon that creates new swap files if your current ones get full. It has saved me at least once from trouble with a memory leak in xdg-desktop-portal-gnome, which I noticed only when I realized I suddenly have 17 GB of swap space shown byhtop
instead of the usual 2 GB.I don't use hibernation. (I tried it briefly ~20 year ago and was disappointed with the speed and reliability. And I think there's a reason distros are not enabling it by default.)
FryBoyter@reddit
I haven't used swap at all for years. For some time now I am using zswap. I can't see any difference in practice for my use cases.
However, if I had to use standard swap, I would definitely use swap files instead of partitions, as they are simpler and more flexible from my point of view.
FranticBronchitis@reddit
16 gigs RAM, 6 GB zram swap (roughly 3 GB when full and compressed), plus a 22 GB partition on spinning rust (my HDD) for hibernation.
Disk swap rarely gets used since zram is there so it's pretty much only there for hibernation.
The zram swap cache was more important before I upgraded from 8 to 16 GB, but it still does end up getting used every once in a while.
UltraEvill@reddit
Hmm, I might not need that much...
oinkbar@reddit
zswap set as half of the RAM. I set to half so it is likely that most of the swap is always compressed in RAM, therefore if system reach a thrashing scenario, it wont be super slow (swapping to disk). I could use zram but find zswap a simpler solution.
matsnake86@reddit
I use zram swap. No other swap partitions.
No-Pin5257@reddit
I use zram swap instead of it.
Asleep-Bonus-8597@reddit
I used to have a swap partition that was created automatically during installation (in Ubuntu). I no longer remember its size but I think it was equal to RAM size. But now I have 16 GB of RAM which is almost infinity so I don't need and don't create a swap at all.
xXBongSlut420Xx@reddit
all the people in this thread saying not to use swap are wrong, even when you have more than adequate memory
https://chrisdown.name/2018/01/02/in-defence-of-swap.html
Iwisp360@reddit
I use Fedora, Fedora uses zram
micush@reddit
Swap on nvme is pretty quick. It's tolerable to use swap with it.
kurupukdorokdok@reddit
I use ZRAM now because it is better than regular swap
ttkciar@reddit
My preferred distribution (Slackware) sets up a ZRAM swap device automatically recently (in -current, not 15.0), but aside from that my habit is no swap partition, create a small swapfile (a few GB) and create more/larger swapfiles as needed, as "/swapfile.1", "/swapfile.2" etc.
I also stick this in my rc.local, to activate any/all swapfiles on system boot, regardless of whether they're in /etc/fstab:
Laughingatyou1000@reddit
Off unless I want to use hibernate.
HeligKo@reddit
Whatever the distro default is usually. Most of my memory issues are created by either I/O caches or my data scientists running their models. The first I fix with tuning and increased swap just exacerbates the situation. The second I fix with communication with my data scientists on how to change how their code runs. Both are solved by doubling the RAM when I can. Different applications might yield different approaches, but for now I'm working with analytics tools and AI. Swapping isn't going to do my customers any favors in these areas.
levi_pl@reddit
Generally no swap. Kubernetes used to require that. Now it is just rationale of tailoring amount of RAM to requirements. Basically there are no scenarios where swap (or rather paging space https://stackoverflow.com/questions/4415254/difference-swapping-and-paging - interesting read) is part of the equation.
WileEPyote@reddit
I have 96GB of ram, so swap is disabled.
When I had 32GB, some of the larger compiles were taking around 75GB of memory with PGO, LTO and some other things enabled, so I just ran a 64GB swap file out of my home partition as needed.
PixelHarvester72@reddit
None. With 32GB RAM, swap just adds unnecessary complexity.
michaelpaoli@reddit
"Disk (drive) is cheap" ... so ... these days, swap, I typically do 1x to 4x RAM. But may also depend on use case scenario, etc. E.g. if I'm doing tmpfs filesystem(s), and depending how large and relative to RAM, I may add more swap. For systems that are relatively tight on RAM, I'll often do more swap.
And, conversely, for some systems I'd rather have crash and burn, and reboot, or spin up another, rather than have performance degrade when under major memory pressure, I may well go with no swap at all.
So ... does rather depend.
And most of the time for swap I'll do that on LVM, notably so I can fairly easily add (or reclaim and free) swap as and when may be relevant/appropriate - don't do a lot of fiddling with that, but sometimes for, e.g. some particular workloads or purposes, may be handy to balloon up the swap space ... then reclaim it later ... e.g. gonna use a ton of space on /tmp and that's tmpfs ... add swap, grow /tmp, and when done, reduce /tmp (yes, tmpfs can be reduced in size while it's mounted), then free up the excess swap that's no longer needed. Maybe a few times per year to once every couple of years or so I'll have some need/reason to do that - generally some specialized workload that needs lots of space for temporary filesystem storage, and where tmpfs is ideal for performance reasons.
Another random example, have a VM with only 1 GiB of RAM ... for reason(s) ... it has lots of swap, ... and with that it generally performs at least quite well enough ... even for the fair amount of work it's doing most all the time.
Your mileage will vary.
thetastycookie@reddit
U need swap to hibernate
JTCPingasRedux@reddit
zram
Independent-Can5874@reddit
1.5 x ram for hibernation . Suspend is not working on my system with Linux .
entrophy_maker@reddit
Zero. There are arguments for and against swap that go back over 30 years. I find that when I need it the most, when the system is completely out of memory, it might keep the host up, but the system and applications are frozen. Basically meaning its worthless. From an anti-forensics perspective, its bad because it will save parts of memory to disk. Some apps like Kubernetes won't even work if Swap is enabled. So I don't use swap at all anymore.
KnowZeroX@reddit
I setup the swap to be 1.5x, you need that if you plan to hibernate. You can also do a swap file instead of a swap partition making it more flexible. I also like to lower the swapiness so that the operating system doesn't use swap unless it is needed
DRAK0FR0ST@reddit
I've been using zram for a few years, the difference in performance compared to swap partitions and swap files is abysmal.
arglarg@reddit
I worried about that when SSDs were expensive, then went back to default swap size = RAM size. On my old laptop that's ok, on a server maybe not so much.
I haven't ever seen it swap though, so it is wasted space, but space I don't need at this time.
raylverine@reddit
My system only has 6GB of soldered ram. I set a 12GB swap file instead of partition. It's excessive but I can only do so much (old rule of swap = 2x ram when ram was limited). Large compilation or even running Minecraft server can devour a lot memory.
jelly_cake@reddit
I don't worry too much - if I need swap, I can always make a swapfile in
/tmp
. ;)jelloshots8607@reddit
when i was setting up my current setup, i ended up just doing the same amount of swap as physical memory. so 16gb of swap lol, gives me plenty of wiggle room if for whatever reason i need it (so far, i dont think its ever been touch)
cla_ydoh@reddit
None on my 32Gb system at the moment, no issues so far. I'll add a \~2Gb swap file if the need arises.
On my other systems, whatever the installer adds, or a 2Gb swap file. I don't hibernate, which is the real reason for larger swaps.
rileyrgham@reddit
A big chunk. disk is even cheaper. 😉 But more seriously, right or wrong, I generally set it to ram size... Old habits die hard.