Skip to content

Instantly share code, notes, and snippets.

@omikun
Created December 7, 2016 19:46
Show Gist options
  • Save omikun/557a996978146eba7a484cdfcb4613ab to your computer and use it in GitHub Desktop.
Save omikun/557a996978146eba7a484cdfcb4613ab to your computer and use it in GitHub Desktop.
limits the maximum memory used by process (ls in example) to 10MB
# Create a memory cgroup named 'mygroup', allowing $USER to change the parameters and run tasks in the cgroup.
sudo cgcreate -a $USER -t $USER -g memory:mygroup
# Set the memory limit to 10MB
echo 10000000 > /sys/fs/cgroup/memory/mygroup/memory.limit_in_bytes
# Run a program in the cgroup
cgexec -g memory:mygroup ls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment