SDB:Ulimit for Protection Against "Out of memory"
Symptom:
You are running several applications (mostly under X). Suddenly, the hard disk seems to work very intensively and the computer slows down until it "freezes". Your machine remains in this state for minutes or even hours.
Cause:
Every now and then and in an irreproducible manner, some applications dubiously programmed try to grab all the available memory. Thus, there is no available memory left for other processes and the computer hangs.
Solution:
Use ulimit to set a limit for the allowed memory requirements of an application. Several parameters can be used with ulimit. The most relevant in this case are the utilization of physical memory and virtual memory. Insert the following lines in your .bashrc :
# for limiting the physical memory: ulimit -m xxxxx # for limiting the virtual memory: ulimit -v xxxxx
Obviously, xxxxx has to be replaced with the corresponding value from your system. On a computer with 128 MB RAM and 128 MB swap, for example, this value would be 98304. Since values for ulimit are specified in kb, 98304 corresponds to 96 MB (96 x 1024 = 98304). You might have to experiment a bit to find the right value for your system. ulimit functions by ending every process that demands more memory than assigned. There is a risk of data loss, but at least your system is up and running (after all, you risk data loss, too, when you have to reset your system after such an error ;-) <keyword>bash,memory,netscape,ulimit</keyword>