diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2015-09-30 21:10:36 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2015-09-30 21:10:36 +0200 |
commit | 1a63e630ae2c0dfa54bda79aa2d0dddbf67e2cc4 (patch) | |
tree | 1b3ace97996b556e0ec6d47c2815df44a4925dbe | |
parent | 55bc5d15c75d5773b11b604e5ac197389a26f3f4 (diff) | |
parent | 9ea99dbf369c498215705650b111e78cd53c94da (diff) | |
download | Nim-1a63e630ae2c0dfa54bda79aa2d0dddbf67e2cc4.tar.gz |
Merge pull request #3345 from rbehrends/no-unmap
Add option to disable munmap() use in the allocator.
-rw-r--r-- | lib/system/alloc.nim | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim index 13a10e46f..3a1d7b666 100644 --- a/lib/system/alloc.nim +++ b/lib/system/alloc.nim @@ -27,8 +27,11 @@ sysAssert(roundup(65, 8) == 72, "roundup broken 2") # some platforms have really weird unmap behaviour: unmap(blockStart, PageSize) # really frees the whole block. Happens for Linux/PowerPC for example. Amd64 # and x86 are safe though; Windows is special because MEM_RELEASE can only be -# used with a size of 0: -const weirdUnmap = not (defined(amd64) or defined(i386)) or defined(windows) +# used with a size of 0. We also allow unmapping to be turned off with +# -d:nimAllocNoUnmap: +const doNotUnmap = not (defined(amd64) or defined(i386)) or + defined(windows) or defined(nimAllocNoUnmap) + when defined(posix): const @@ -478,7 +481,7 @@ proc freeBigChunk(a: var MemRegion, c: PBigChunk) = excl(a.chunkStarts, pageIndex(c)) c = cast[PBigChunk](le) - if c.size < ChunkOsReturn or weirdUnmap: + if c.size < ChunkOsReturn or doNotUnmap: incl(a, a.chunkStarts, pageIndex(c)) updatePrevSize(a, c, c.size) listAdd(a.freeChunksList, c) @@ -762,7 +765,7 @@ proc deallocOsPages(a: var MemRegion) = # we free every 'ordinarily' allocated page by iterating over the page bits: for p in elements(a.chunkStarts): var page = cast[PChunk](p shl PageShift) - when not weirdUnmap: + when not doNotUnmap: var size = if page.size < PageSize: PageSize else: page.size osDeallocPages(page, size) else: |