From 67b635029d13c240b081c84cd8a0f8a86137212b Mon Sep 17 00:00:00 2001 From: Hakan Deryal Date: Thu, 13 Oct 2016 19:08:31 +0300 Subject: [PATCH 1/2] fixes memory region not updating when passed to withRegion template. --- lib/system/gc_stack.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/system/gc_stack.nim b/lib/system/gc_stack.nim index 5f72b89590..6f492c3070 100644 --- a/lib/system/gc_stack.nim +++ b/lib/system/gc_stack.nim @@ -79,6 +79,7 @@ template withRegion*(r: MemRegion; body: untyped) = try: body finally: + r = tlRegion tlRegion = oldRegion template inc(p: pointer, s: int) = From 34865fbbf5fd88406e1e901246c03dd377fc9fa1 Mon Sep 17 00:00:00 2001 From: Hakan Deryal Date: Thu, 13 Oct 2016 19:10:53 +0300 Subject: [PATCH 2/2] add exported memory size getter functions for MemRegion objects --- lib/system/gc_stack.nim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/system/gc_stack.nim b/lib/system/gc_stack.nim index 6f492c3070..3eda08df97 100644 --- a/lib/system/gc_stack.nim +++ b/lib/system/gc_stack.nim @@ -465,4 +465,10 @@ proc getFreeMem(): int = tlRegion.remaining proc getTotalMem(): int = result = tlRegion.totalSize +proc getOccupiedMem*(r: MemRegion): int = + result = r.totalSize - r.remaining +proc getFreeMem*(r: MemRegion): int = r.remaining +proc getTotalMem*(r: MemRegion): int = + result = r.totalSize + proc setStackBottom(theStackBottom: pointer) = discard