logoalt Hacker News

loeglast Friday at 8:40 PM3 repliesview on HN

Surely the source of the waste here is the userspace program not using the memory it allocated, rather than whether or not the kernel overcommits memory. Attributing this to overcommit behavior is invalid.


Replies

PunchyHamsteryesterday at 3:09 AM

The waste comes with asterisk

That "waste" (that overcommit turns into "not a waste") means you can do far less allocations, with overcommit you can just allocate a bunch of memory and use it gradually, instead of having to do malloc() every time you need a bit of memory and free() every time you get rid of it.

You'd also increase memory fragmentation that way possibly hitting performance.

It's also pretty much required for GCed languages to work sensibly

jcalvinowenslast Friday at 8:44 PM

Obviously. But all programs do that and have done it forever, it's literally the very reason overcommit exists.

show 1 reply
nickelprolast Friday at 8:56 PM

Reading COW memory doesn't cause a fault. It doesn't mean unused literally.

And even if it's not COW, there's nothing wrong or inefficient about opportunistically allocating pages ahead of time to avoid syscall latency. Or mmapping files and deciding halfway through you don't need the whole thing.

There are plenty of reasons overcommit is the default.