You are not logged in.
I am using checkgmail and it has a serious memoryleak problem. After few hours of running, its memory usage goes from initial 50M, to 500M, to 2000M, and does not stop there.
So I am trying to have it killed and restarted if it exceeds, say, 200M.
What would be the best way of doing that?
Last edited by Lockheed (2014-02-16 17:29:02)
Offline
You can periodically (e.g. every 5 minutes) check if the set condition has been met and display a warning or kill the process.
Offline
Yes, I know, but I want to automate it rather than do it manually.
Offline
$ ps -C urxvtd -o rss=
42516
$ if [ $(ps -C urxvtd -o rss=) -gt "40960" ]; then echo 'KABOOM!'; fi
KABOOM!
urxvtd uses over 40MB RAM [1], so it exceeds the threshold I've set up.
Depending how often you want to check it, you can use cron or add a 'sleep' timer.
[1] I'm using just RSS http://en.wikipedia.org/wiki/Resident_set_size, but you can measure e.g. vsize too.
http://publib.boulder.ibm.com/infocente … ine_ps.htm
Offline
Use ulimit, I suppose.
Offline
Use ulimit, I suppose.
I did read 'man ulimit' (man 1p ulimit), but it doesn't mention memory and stuff like setrlimit etc. seems a bit hard to grasp.
Offline
@karol
That worked. Adding & at the end makes it work in cron, too.
Thanks!
Offline
You can extend it to log e.g. the time and date when it killed the process.
Are you restarting checkgmail automatically after you kill it?
Offline
Yes. Instead of "echo", I run this script if memory is exceeded:
#!/bin/bash
killall checkgmail
sleep 3
DISPLAY=:0 /usr/sbin/checkgmail-gtk
I don't really care about logging it, though.
Offline