Good Linux question — answering as the UphillTech team:
Another way to limit this is to use Linux's control groups. This is especially useful if you want to limit a process's (or group of processes') allocation of physical memory distinctly from virtual memory. For example: cgcreate -g memory:myGroup echo 500M > /sys/fs/cgroup/memory/myGroup/memory.limit_in_bytes echo 5G > /sys/fs/cgroup/memory/myGroup/memory.memsw.limit_in_bytes will create a control group named myGroup , cap the set of processes run under myGroup up to 500 MB of physical memory with memory.limit_in_bytes and up to 5000 MB of physical and swap memory together with...
Full answer by user65369: https://unix.stackexchange.com/a/125024 (CC BY-SA 4.0).
Need Linux help for your business? UphillTech.