Change MAPMapPEFile to use ExecutableAllcator instead of mmap to reserve VA
authorSergiy Kuryata <sergeyk@microsoft.com>
Thu, 18 Feb 2016 01:40:30 +0000 (17:40 -0800)
committerSergiy Kuryata <sergeyk@microsoft.com>
Thu, 18 Feb 2016 01:40:30 +0000 (17:40 -0800)
commitb1e9fa4403180ab5298008efb24142ff164c4b57
tree5ebce11e9431955d62be9d05d6abe8aca1e212a1
parentb234866bd2a1b4674850c28f980f116042b8b8ea
Change MAPMapPEFile to use ExecutableAllcator instead of mmap to reserve VA

This change modifies the MAPMapPEFile in PAL to use ExecutableAllcator
instead of mmap in order to reserve VA for managed executable images. This
allows all NI images to be located near each other and close to the
coreclr library, which also allows the runtime to generate code that is
more efficient (by avoiding usage of jump stubs).

It also fixes an issue (https://github.com/dotnet/cli/issues/652) where
CLI fails with OutOfMemoryException which turned out to be related to
loading NI files. Due to a certain allocation pattern, mmap can place an
NI file at a region of virtual address space that does not have any free
memory around the NI images. As a result, when the runtime needs to
allocate memory for jump stubs for the image it cannot find any available
memory near the image and fails with OutOfMemoryException.
src/pal/src/include/pal/virtual.h
src/pal/src/map/map.cpp
src/pal/src/map/virtual.cpp