I'm looking for a way to execute a script as my RAM fills up, right before my machine starts swapping heavily and blocks my mouse, keyboard and other input devices for some minutes.
The thing is that I'm developing software, and it's pretty hefty in terms of memory use. Usually its my fault if it does fill up my RAM, but I need a way to auto-kill the app I'm developing when this happens. (Or preferably right before)
Can I receive events from the OS itself? Or from maybe the system monitor? I need some lightweight, and preferably non-polling way of doing this.
I'm running Ubuntu 11.04 btw.
ulimit
is a better solution than disabling swap. ;-) But potentially just as dangerous if wielded incorrectly. (also, I work on embedded systems, so the notion of having swap space available at all in my development environment is a bit laughable) ;-)