ubuntu - How Limit memory usage for a single Linux process and not kill the process -


how limit memory usage single linux process , not kill process.

i know ulimit can limit memory usage, if exceed limit, kill process.

is there other command or shell can limit memory usage , not kill process?

another way besides setrlimit, can set using ulimit utility:

$ ulimit -sv 500000 # set ~500 mb limit

is use linux's control groups, because limits process's (or group of processes') allocation of physical memory distinctly virtual memory. example:

$ cgcreate -g memory:/mygroup
$ echo $(( 500 * 1024 * 1024 )) > /sys/fs/cgroup/memory/mygroup/memory.limit_in_bytes
$ echo $(( 5000 * 1024 * 1024 )) > /sys/fs/cgroup/memory/mygroupmemory.memsw.limit_in_bytes

will create control group named "mygroup", cap set of processes run under mygroup 500 mb of physical memory , 5000 mb of swap. run process under control group:

$ cgexec -g memory:mygroup command

note: can understand setrlimit limit virtual memory, although cgroups can limit physical memory.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -