summary refs log tree commit diff stats
path: root/lib/system/alloc.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system/alloc.nim')
-rw-r--r--lib/system/alloc.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim
index 6d83a2c17..2c6ab4462 100644
--- a/lib/system/alloc.nim
+++ b/lib/system/alloc.nim
@@ -1054,9 +1054,12 @@ template instantiateForRegion(allocator: untyped) {.dirty.} =
         it = it.next
 
   when hasThreadSupport:
+    proc addSysExitProc(quitProc: proc() {.noconv.}) {.importc: "atexit", header: "<stdlib.h>".}
+
     var sharedHeap: MemRegion
     var heapLock: SysLock
     initSysLock(heapLock)
+    addSysExitProc(proc() {.noconv.} = deinitSys(heapLock))
 
   proc getFreeMem(): int =
     #sysAssert(result == countFreeMem())