3 ms·
Linux actually will let you allocate address space without allocating pages. You just disable all access and the OS knows that it doesn't actually need to give
by rageoholic 5y ago
Linux actually will let you allocate address space without allocating pages. You just disable all access and the OS knows that it doesn't actually need to give you any pages. You then commit by using mprotect to enable access to the page. There are madvise hints you can use to tell the OS that you no longer care about what's in the page, although they're a bit misnamed for compatibility reasons(MADV_DONTNEED will immediately free the pages while MADV_FREE will lazily free the pages)
Edit: Actually it looks like the behavior might have changed. hmmm. I guess read the man pages tied to the kernel you're using
Edit 2: Nope, I misread the most recent manpage. I should not read manpages when I'm tired. It does zero fill specifically for anonymous mappings