5 ms·
Strangely, alloc checks no longer work in Linux and possibly other OSes. Because of overcommit you can have malloc give you an non-NULL result that will fail wh
by jws 14y ago
Strangely, alloc checks no longer work in Linux and possibly other OSes. Because of overcommit you can have malloc give you an non-NULL result that will fail when you try to write to it.
I still include them in my code, but I don't expect they will save me.
- loeg 14y agoHowever, it is perfectly possible in Linux to turn overcommit off. So you still need to check (or segfault…).
- halayli 14y agomalloc failure isn't just bound to running out of physical memory. It can fail because of fragmentation, with or without overcommit.
- jws 14y agoSure, but I still have to design for random segfaults on memory writes. I guess I could write to all newly allocated pages and get a little more assurance that the allocation worked. I could still be whacked by a deduplicator, though unique writes would help.