Hi,
/etc/systemd/system/user-firefox.slice
```
[Unit]
Description=Firefox Slice
Before=slices.target
[Slice]
MemoryAccounting=true
MemoryLimit=512M
```
Then you can run
```
systemctl daemon-reload && systemctl restart user-firefox.slice
```
Then launch Firefox in the slice like so
```
systemd-run -q --user --scope --unit ff \
--slice user-firefox -- firefox --profile myprofile
```
Which will apply the limits in the slice (check the docs, there's all sorts) to anything running within it. You can enable the slice and run Firefox (or anything else you want to limit, really).
You may need to adapt these commands a little, I wrote this on mobile. :)
I use slices on HPC to limit users from monopolising interactive nodes, and our batch jobs kill anything that exceeds requested memory (hope that wasn't 100h into a job!). I do this on login with user slices but the concept is the same.
Here's the docs on slice/scope settings:
https://www.freedesktop.org/software/systemd/man/latest/systemd.resource-control.html#
You could also try something like this:
https://github.com/mk-fg/fgtk#cgrc
You can directly do cgroups on openrc... Probably? I've never had to worry about it.
Cheers,
Matt
On 24 Aug 2024 07:22, Wol <antli...@youngman.org.uk> wrote:
On 23/08/2024 19:38, Dale wrote:
> Any ideas on how to limit Firefox memory usage? Wouldn't mind if I
> could use it for other programs too.
cgroups? Dunno how they work, but it's something they're supposed to do ...
Cheers,
Wol