I mean somehow I have to tell Nim when to free memory right?
Yeah sure, you just use these: alloc, dealloc, allocShared, deallocShared. You can cast the pointer from and to ptr types and then you have your manually managed heap memory.
(This is a general answer to how to use non-GC'd memory and has nothing to do with memory regions)
Compile with --gc:stack
var rx: Region
withRegion rx:
... json code here ...
You're right though that it needs documentation. I don't even know if it's in 0.14.
@Araq Is there any discussion anywhere of the region memory model? You cannot expect people to just guess that it exists...
I am not sure if this is supposed to work right now, but I tried
import system/gc_stack
var rx: Region
withRegion rx:
discard 0
(compiling with --gc:stack) and I get the error
lib/system/osalloc.nim(12, 3) Error: undeclared identifier: 'sysAssert'
I am not sure I should import system/gc_stack but without it I cannot find the symbols Region and withRegion)
Well ok, it's called MemRegion, so this compiles with --gc:stack:
var rx: MemRegion
withRegion rx:
discard 0