Re:Systemd 248 RC3: systemd-oomd is now considered fully sup...
by scaladev on Sunday March 14, 2021 @11:28AM
(#26456171)
If you're using systemd, drop docker and start your browser through something like this:
#!/bin/sh
systemd-run \
--user \
--scope \
--property=MemoryHigh=4G \
--slice=background \
/usr/bin/firefox "$@"
Theoretically this does not prevent Firefox from using more than 4 GBs of memory (you need MemoryMax for that), but practically it does. MemoryHigh=bytes
Specify the throttling limit on memory usage of the executed processes in this unit. Memory usage may go above the limit if unavoidable, but the processes are heavily slowed down and memory is taken away aggressively in such cases. This is the main mechanism to control memory usage of a unit.
MemoryMax=bytes
Specify the absolute limit on memory usage of the executed processes in this unit. If memory usage cannot be contained under the limit, out-of-memory killer is invoked inside the unit. It is recommended to use MemoryHigh= as the main control mechanism and use MemoryMax= as the last line of defense.
I use a similar script to prevent my torrent client from pushing more useful data out of the page cache.You can put resource limits on basically anything (see systemd.resource-control(5)).
Re:Systemd 248 RC3: systemd-oomd is now considered fully sup...
by arp242 on Sunday March 14, 2021 @11:58AM
(#26456377)
Docker is pretty overkill for this; you can just create a new cgroup with a maximum memory, CPU, etc.
Re:Systemd 248 RC3: systemd-oomd is now considered fully sup...
by anthk on Sunday March 14, 2021 @12:41PM
(#26456663)
OpenBSD has login.conf
Re:Systemd 248 RC3: systemd-oomd is now considered fully sup...
by upofadown on Sunday March 14, 2021 @01:22PM
(#26456964)
Speaking of which, Firefox behaviour has improved on OpenBSD significantly recently. It used to either crash or act weird when it hit the memory limit in login.conf (which it would eventually do). Now it just works. No idea what changed.
> Modern browsers are not good "desktop citizens", if you will. They hog memory to the point where opening anything new will create a pressure stall.
I went the ballistic route: most of my browsers run inside local Docker containers, on which I put CPU and RAM quota.
It's my machine: I decide how "citizens" behave : )