Hacker News new | ask | show | jobs
by mono442 29 days ago
The problem with disabling the memory overcommit is that then the RAM is wasted. That can be worked around with setting up swap but then the disk space is wasted.
2 comments

People like to reinvent things that they are not aware of. Original BSDs used to use strict swap reservation - every anonymous memory page had to have an associated swap page. You had to have the swap 2x of RAM to allow large processes to fork - otherwise you would get an "out of swap" error. FreeBSD implemented overcommit around 2000, I think version 4.x or 5.x.
Why are programs even allocating memory that they don't use?
Because no one can predict the future, and they don't know how many resources they will need.
I mean they can just malloc when they need more, what am I missing? Unless this is about JVMs which might preallocate a ton for their heaps and not use it
Apps could, yes.

But it’s about 1000x slower to call the OS to allocate a new page, than to just use a pointer to preallocated space.