Skip to content
Snippets Groups Projects
Commit abab9157 authored by Ben Gamari's avatar Ben Gamari Committed by GHC GitLab CI
Browse files

rts: Allocate MBlocks with MAP_TOP_DOWN on Windows

As noted in #18991, we would previously allocate heap in low memory.
Due to this the linker, which typically *needs* low memory, would end up
competing with the heap. In longer builds we end up running out of
low memory entirely, leading to linking failures.

(cherry picked from commit a1a75aa9)
parent 658b7fc9
No related branches found
No related tags found
No related merge requests found
...@@ -67,8 +67,11 @@ allocNew(uint32_t n) { ...@@ -67,8 +67,11 @@ allocNew(uint32_t n) {
alloc_rec* rec; alloc_rec* rec;
rec = (alloc_rec*)stgMallocBytes(sizeof(alloc_rec),"getMBlocks: allocNew"); rec = (alloc_rec*)stgMallocBytes(sizeof(alloc_rec),"getMBlocks: allocNew");
rec->size = ((W_)n+1)*MBLOCK_SIZE; rec->size = ((W_)n+1)*MBLOCK_SIZE;
// N.B. We use MEM_TOP_DOWN here to ensure that we leave the bottom of the
// address space available for the linker and libraries, which in general
// want to live in low memory. See #18991.
rec->base = rec->base =
VirtualAlloc(NULL, rec->size, MEM_RESERVE, PAGE_READWRITE); VirtualAlloc(NULL, rec->size, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE);
if(rec->base==0) { if(rec->base==0) {
stgFree((void*)rec); stgFree((void*)rec);
rec=0; rec=0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment