I learned the other day that Linux really does kill processes if it runs out of memory. I had detached the swap with swapoff command before that happened. Usually, if any process takes up all the memory by a bug, say memory leak in a loop, my system hanged(I know, technically it's just really really slow), not killing the bad process.
How do I prevent this? No software is perfect and I get to run poorly coded programs and encounter this problem every now and then. I have to reset my system every time. Is this just the limitation of modern kernels? I can't just turn off swap because I know the kernel utilises its swap to some extent to utilise physical memory efficiently even if the physical memory is spacious.
Using smaller size of swap might be an option(shorter time before OOM).