Created
July 23, 2023 09:40
-
-
Save yugr/270a376d323045df82d0cf462207fac8 to your computer and use it in GitHub Desktop.
Using cgroups to limit Memory usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Based on https://www.flamingbytes.com/blog/cgroups-limit-memory/ | |
Install prerequisites: | |
$ apt install libcgroup libcgroup-tools | |
Create new group: | |
$ cgcreate -g memory:/memlimited | |
Set limit: | |
$ echo 32G > /sys/fs/cgroup/memory/memlimited/memory.limit_in_bytes | |
$ cgset -r memory.limit_in_bytes=32G memlimited | |
Limit usage for current shell and subprocesses: | |
$ echo $$ > /sys/fs/cgroup/memory/memlimited/tasks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment