3 ms·
There's two things that cause this. First, Windows has a variable swap file size, whereas Linux has a fixed size, so Windows can just fill up your drive, inste
by dlcarrier 8mo ago
There's two things that cause this. First, Windows has a variable swap file size, whereas Linux has a fixed size, so Windows can just fill up your drive, instead of running out of swap space. Second, the default behavior for the out-of-memory killer in Linux isn't very aggressive, with the default behavior being to over-commit memory instead of killing processes.
As far as I know, Linux still doesn't support a variable-sized swap file, but it is possible to change how aggressively it over-commits memory or kills processes to free memory.
As to why there differences are there, they're more historical than technical. My best guess is that Windows figured it out sooner, because it has always existed in an environment where multiple programs are memory hogs, whereas it wasn't common in Linux until the proliferation of web-based everything requiring hundreds of megabytes to gigabytes of memory for each process running in a Chrome tab or Electron instance, even if it's something as simple as a news article or chat client.
Check out this series of blog posts. for more information on Linux memory management: https://dev.to/fritshooglandyugabyte/series/16577 https://dev.to/fritshooglandyugabyte/series/16577
- LargoLasskhyfv 8mo ago> As far as I know, Linux still doesn't support a variable-sized swap file... You can add (and remove) additional swapfiles during runtime, or rather on demand. I'm just unaware of any mechanism doing that automagically, though. Could probably done in eBPF and some shell scripts, I guess?
- dsr_ 8mo agoswapspace (https://github.com/Tookmund/Swapspace https://github.com/Tookmund/Swapspace) does this. Available in Debian stable.
- LargoLasskhyfv 8mo agoWow. Since 20 years. And I'm rambling about eBPF...
- dlcarrier 8mo agoLinux's ePBF has its issues, too. I once was trying to set up a VPN that needed to adjust the TTL to keep its presence transparent, only to discover that I'd have to recompile the kernel to do so. How did packet filtering end up privileged, let alone running inside the kernel? I recently started using SSHFS, which I can run as an unprivileged user, and suspending with a drive mounted reliably crashes the entire system. Back on the topic of swap space, any user that's in a cgroup, which is rarely the case, can also crash the system by allocating a bunch of RAM. Linux is one of the most advanced operating systems in existence, with new capabilities regularly being added in, but it feels like it's skipped over several basics.
- Joker_vD 8mo agoWindows "figured it out sooner" because it never really had to seriously deal with overcommitting memory: there is no fork(), so the memory usage figures of the processes are accurate. On Linux, however, the un-negotiable existence of fork() really leaves one with no truly good solution (and this has been debated for decades).
- goodpoint 8mo agofork is a massive feature, not a bug.
- tliltocatl 8mo agofork() is a misfeature, as is SIGCHILD/wait and most of Unix process management. It worked fine on PDP-11 and that's it. But Linux also overcommits mmap-anonymous/sbrk, while Windows leaves the decision to the user space, which is significantly slower.
- rwmj 8mo agoNot really. It elegantly solves the "create a process, letting it inherit these settings and reset these other settings", where "settings" is an ever changing and expanding list of things that you wouldn't want to bake into the API. Thus (omitting error checks and simplifying many details): pipe (fd[2]); // create a pipe to share with the child if (fork () == 0) { // child close (...); // close some stuff setrlimit (...); // add a ulimit to the child sigaction (...); // change signal masks // also: clean the environment, set cgroups execvp (...); // run the child } It's also enormously flexible. I don't know any other API that as well as the above, also lets you change the relationship of parent and child, and create duplicate worker processes. Comparing it to Windows is hilarious because Linux can create processes vastly more efficiently and quickly than Windows.
- tliltocatl 8mo agoYes, but at what cost? 99% of fork calls are immediately followed by exec(), but now every kernel object need to handle being forked. And a great deal of memory-management housekeeping is done only to be discarded afterward. And it doesn't work at all for AMP systems (which we will have to deal with, sooner or latter). In 1970 it might have been the only way to provide a flexible API, but nowadays we have a great variety of extensible serialization formats better than "struct".
- ChocolateGod 8mo agoWindows will also prioritise to keep the desktop and current focussed application running smoothly, the Linux kernel has no idea what's currently focused or what not to kill, your desktop shell is up there on the menu in oom situations.
- p_ing 8mo agoThe same behavior exists as far back as NT4 Server, which does not provide a foreground priority boost by default.
- quotemstr 8mo agoHuh? What does swap area size have to do with responsiveness under load? Linux has a long history of being unusable under memory pressure. systemd-oomd helps a little bit (killing processes before direct reclaim makes everything seize up), but there's still no general solution. The relevance to history is that Windows got is basically right ever and Linux never did. Nothing to do with overcommit either. Why would that make a difference either? We're talking about interactivity under load. How we got to the loaded state doesn't matter.
- deleted 8mo ago[deleted]
- kalaksi 8mo agoThere are daemons (not installed by default) that monitor memory usage and can increase swap size or kill processes accordingly (you can ofc also configure OOM killer).
- man8alexd 8mo agoThere are some mistakes in these blog posts, especially the one about overcommit.