For what I understand, when the system is close to have no free memory, the kernel should start to kill processes to regain some memory. But in my system this does not happen at all.
Suppose a simple script that just allocates much more memory than the available in the system (an array with millions of strings, for example). If I run a script like this (as a normal user), it just gets all the memory until the system completely freezes (only SysRQ REISUB works).
The weird part here is that when the computer freezes, the hard drive led turns on and stays that way until the computer is rebooted, either if I have a swap partition mounted or not!
So my questions are:
- Is this behavior normal? It's odd that an application executed as a normal user can just crash the system this way...
- Is there any way I can make Ubuntu just kill automatically those applications when they get too much (or the most) memory?
Additional information
- Ubuntu 12.04.3
- Kernel 3.5.0-44
RAM: ~3.7GB from 4GB (shared with graphics card).
*
$ tail -n+1 /proc/sys/vm/overcommit_*
==> /proc/sys/vm/overcommit_memory <==
0
==> /proc/sys/vm/overcommit_ratio <==
50
$ cat /proc/swaps
Filename Type Size Used Priority
/dev/dm-1 partition 4194300 344696 -1