Am 30.11.2026 um 07:00 schrieb Lawrence D’Oliveiro:
> You don’t even need a special wrapper to achieve that. On Linux > systems, you can set the memory-allocation policy to “overcommit”, > which basically means that, when a process asks for memory, the > kernel never says no <https://manpages.debian.org/proc_sys_vm(5)>. > > So you don’t even need to bother to check for memory-allocation > failures, because you will never get a failure status. Instead, > if/when the system runs low on memory, a kernel thread known as “the > dreaded OOM killer” is loosed from the mythical underground cave where > it is normally kept chained, and it starts killing processes, starting > with the biggest memory hogs, until sanity, in the form of an adequate > memory reserve, is restored to the system. > > In fact, this overcommit policy is usually the default setting.
realloc() may be necessary nevertheless when a memory chunk isn't large enough. With overcommit you could allocate more memory than needed to reduce the likehood of realloc()s.