Hacker News new | ask | show | jobs
by Asooka 3071 days ago
Windows also has two syscalls - one to reserve memory and one to commit memory. You can reserve+commit at once, but you can also just reserve a chunk of virtual memory that you commit at a later time. Accessing pages that aren't committed is a segfault. So you can say "I might need up to X contiguous bytes of virtual memory" and then commit as you go. IIRC, Windows will let you over-reserve, but not over-commit.

Edit: sorry, not two syscals, it's an option to the malloc-equivalent - VirtualAlloc