StephanvanSchaik / mmap-rs

A cross-platform and safe Rust API to create and manage memory mappings in the virtual address space of the calling process.
Apache License 2.0
59 stars 17 forks source link

Ensure map_none does not commit pages on Microsoft Windows #13

Closed StephanvanSchaik closed 1 year ago

StephanvanSchaik commented 1 year ago

This PR attempts to tackle the problem outlined in PR #12 by ensuring that Mmap::map_none() only reserves a region in the virtual address space, but does not yet allocate any physical pages for that region. This behavior should align well with the behavior of other platforms.

Since the user has no access to the page, it should be safe to simply reserve but not commit the memory mapping avoiding the need for UnsafeFlags for this particular use case.

When using one of the functions to change the protection of the memory mapping, and the memory mapping is not yet in a committed state, we commit the pages.

The use case of committing pages with the no access protection will be supported in a separate commit.