You can reserve a large, contiguous address space by using mmap
with PROT_NONE
(no permissions). Then, you can later "grow" into this allocation by using mprotect
to update a segment with the proper permissions. This way, you can mmap
the maximum amount of memory needed, which will ensure the pages are virtually continuous but not yet mapped to a physical page until the protections are incrementally updated.