I have a Zope server (just a long running python process) which tends to eat up all RAM on my server after a couple of days. I do not want to restart it every night - maybe it's better to limit the RAM for this process and see if it can work anyway.
So, how can I restrict this process to use not more than 256MB of RAM?
The Server is a 64bit Intel machine running Centos 5.3. I heard of ulimit to restrict a bash process, but how can I restrict it for a python process?
Update:
Thank you for your ideas! I am going to use a mixed approach for my problem:
- I'll start the service with ulimit so it can only use 256MB RAM
- Since I have my system monitored by Nagios, I'll use a nagios-check command to verify that my process is not using more than 192MB.
- If my process uses more than 192MB, then a graceful restart will be initiated automatically.
- If my process uses more than 220MB or the process does not run at all, an admin (myself) will be informed via SMS/E-Mail, so I will handle the problem manually.
That way I guess that I am on the safe side: automatic graceful restarts when needed (via nagios), and forced service stops (via ulimit) in case of a sudden peak in its RAM usage