diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2015-11-01 10:18:41 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-11-01 10:18:52 +0100 |
commit | 4ad2a8f9a503a5ee060eb8e0d5ae71b98d605cfa (patch) | |
tree | 0b62a58a13f8f03da9a0344aa5057ded082c3785 /rts/win32/OSMem.c | |
parent | c3b02150b516963422ed4b9b200a38814a35b535 (diff) | |
download | haskell-4ad2a8f9a503a5ee060eb8e0d5ae71b98d605cfa.tar.gz |
rts/posix: Reduce heap allocation amount on mmap failure
Since the two-step allocator the RTS asks the kernel for a large upfront
mmap'd region of memory (on the order of terabytes). While we have no
expectation that this entire region will be backed by physical memory,
this scheme nevertheless fails on some systems with resource limits.
Here we use a back-off scheme to reduce our allocation request until we
find a size agreeable to the kernel. Fixes #10877.
This also fixes a latent bug wherein the heap reservation retry logic
would fail to free the previously reserved address space, which would
likely result in a heap allocation failure.
Test Plan:
set address space limit with `ulimit -v 67108864` and try running
a compiled program
Reviewers: simonmar, austin
Reviewed By: simonmar
Subscribers: thomie, RyanGlScott
Differential Revision: https://phabricator.haskell.org/D1405
GHC Trac Issues: #10877
Diffstat (limited to 'rts/win32/OSMem.c')
-rw-r--r-- | rts/win32/OSMem.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/rts/win32/OSMem.c b/rts/win32/OSMem.c index 2d2af0ddf6..47e24f077a 100644 --- a/rts/win32/OSMem.c +++ b/rts/win32/OSMem.c @@ -429,11 +429,11 @@ void setExecutable (void *p, W_ len, rtsBool exec) static void* heap_base = NULL; -void *osReserveHeapMemory (W_ len) +void *osReserveHeapMemory (W_ *len) { void *start; - heap_base = VirtualAlloc(NULL, len + MBLOCK_SIZE, + heap_base = VirtualAlloc(NULL, *len + MBLOCK_SIZE, MEM_RESERVE, PAGE_READWRITE); if (heap_base == NULL) { if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY) { |