Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

When your system is out of memory, you do not want to return an error to the next process that allocates memory. That might be an important process, it might have nothing to do with the reason the system is out of memory, and it might not be able to gracefully handle allocation failure (realistically, most programs can't).

Instead, you want to kill the process that's hogging all the memory.

The OOM killer heuristic is not perfect, but it will generally avoid killing critical processes and is fairly good at identifying memory hogs.

And if you agree that using the OOM killer is better than returning failure to a random unlucky process, then there's no reason not to use overcommit.

Besides, overcommit is useful. Virtual-memory-based copy-on-write, allocate-on-write, sparse arrays, etc. are all useful and widely-used.





OOM killer often doesn't run soon enough for me; I've even left the machine for twenty minutes and it's still swapping hard.

And I do say "often" because it does sometimes work.

I have set all my Firefox processes near-maximum priority to kill for the OOM killer, but it didn't help.

Also don't forget about memory compression: only meaningful with overcommit.


Yeah, you probably want something that activates a bit earlier. I think the issue is the OOM killer won't activate until essentially everything that can be paged out is paged out, and that includes most code pages, so the system enters a death spiral of paging code in and out and stops making progress towards a point where the OOM killer would kick in. There's userspace daemons like earlyoom that help a lot with this.

They say swap is highly highly recommended even if you have plenty of memory.

I don't care, I disable it anyway. Have been doing so for decades. Never caused a problem.


Run without swap or with very little swap. I'm serious. Your modern server has enough memory, way more than 4MB, and you care about consistent latency don't you? Also, swap is wearing our your SSD.

It will happen even without swap. Code pages will get evicted and everything will slow down to a crawl. I have magic SysRq enabled so I can invoke OOM killer from keyboard if that happens.

You can't be serious having both 'your modern server has enough memory' and 'swap is wearing out your SSD' in the same sentence.

Even 0.3 DWPD drives have years before wearing out and in your modern server you really should have something with >= 1 DWPD.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: