3 ms·
I'm a little disappointed that the article didn't answer the question, or at least try to. A discussion of using read/write vs mincore vs trying to catch a SIGS
by mirashii 5y ago
I'm a little disappointed that the article didn't answer the question, or at least try to. A discussion of using read/write vs mincore vs trying to catch a SIGSEGV would've been a nice addition.
- kibwen 5y agoThe answer is that you kind of can't. You're at the mercy of the OS to give you accurate information, and malloc as an interface isn't set up to distinguish between virtual memory and "actual" memory. We could imagine a separate interface that would allow the OS to communicate this distinction (or hacks like you allude to), but I don't know of any standard approach.
- convolvatron 5y agobefore linux - every unix OS would fail a page allocation if there wasn't a backing store. full stop. this worked really well
- ungamedplayer 5y agoUntil it didn't.
- marcosdumay 5y agoIt has always lead to all kinds of problems, like computers becoming inaccessible, and corrupted data because of segfaults between disk accesses. And also nobody ever checked the malloc result anyway. Competent programmers just ensured that the segfault wasn't a huge problem. So at the best of the days, all it did was reducing the capacity of the computer.
- rurban 5y agolibsigsegv. Used to catch out of memory errors to start a major GC.
- dezgeg 5y agoHmm, I don't think that one would help with OOM killer termination either.