How to setup limit for process to memory usage?
Similar to open files limit in /etc/security/limits.conf
:
ubuntu soft nofile 4096
ubuntu hard nofile 8192
E.g. while I'm launching python script with raw eval
of json data from 1.1G file, python takes whole of RAM, while creating objects around each dict
and list
in json.txt
. It hung my machine for 20-30 minutes. Thereafter:
# python read_data.py
Killed
Ubuntu System is very stable today. Its recovery from hung. Swap going to 8Gb of usage. RAM completely empty, script going off.
I'm trying to find, is this limit, which killed
my script configurable? Can I tune my system in such way, that every process, which takes more than 70% of current RAM size would be just killed or stopped or something.
as
(address space) limitation. – Bratchley Aug 29 '14 at 11:36ulimit -v 4000000
protect my system from hunging, while I'm playing with python. – youblind Aug 29 '14 at 11:41