diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-09-18 11:55:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-18 11:55:58 +0200 |
commit | d19316bbb986a7dd1d6d091173963f6e74c65991 (patch) | |
tree | 962eb2e81643561db16e49a4647385dd75b5ac38 /tests | |
parent | 59b7857167ad458290dc57c4e39ca564b3080e52 (diff) | |
download | Nim-d19316bbb986a7dd1d6d091173963f6e74c65991.tar.gz |
more ORC bugfixes (#15355)
* introduced --define:nimArcIds * ORC: bugfixes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/arc/tasyncleak.nim | 2 | ||||
-rw-r--r-- | tests/arc/tasyncleak3.nim | 46 |
2 files changed, 47 insertions, 1 deletions
diff --git a/tests/arc/tasyncleak.nim b/tests/arc/tasyncleak.nim index 71d62222d..72aa3d4c2 100644 --- a/tests/arc/tasyncleak.nim +++ b/tests/arc/tasyncleak.nim @@ -1,5 +1,5 @@ discard """ - outputsub: "(allocCount: 4016, deallocCount: 4010)" + outputsub: "(allocCount: 4016, deallocCount: 4014)" cmd: "nim c --gc:orc -d:nimAllocStats $file" """ diff --git a/tests/arc/tasyncleak3.nim b/tests/arc/tasyncleak3.nim new file mode 100644 index 000000000..c1510895a --- /dev/null +++ b/tests/arc/tasyncleak3.nim @@ -0,0 +1,46 @@ +discard """ + cmd: "nim c --gc:orc $file" + output: "true" +""" + +import strutils + +type + FutureBase* = ref object of RootObj ## Untyped future. + finished: bool + stackTrace: seq[StackTraceEntry] ## For debugging purposes only. + +proc newFuture*(): FutureBase = + new(result) + result.finished = false + result.stackTrace = getStackTraceEntries() + +type + PDispatcher {.acyclic.} = ref object + +var gDisp: PDispatcher +new gDisp + +proc testCompletion(): FutureBase = + var retFuture = newFuture() + + iterator testCompletionIter(): FutureBase {.closure.} = + retFuture.finished = true + when not defined(nobug): + let disp = gDisp # even worse memory consumption this way... + + var nameIterVar = testCompletionIter + proc testCompletionNimAsyncContinue() {.closure.} = + if not nameIterVar.finished: + discard nameIterVar() + testCompletionNimAsyncContinue() + return retFuture + +proc main = + for i in 0..10_000: + discard testCompletion() + +main() + +GC_fullCollect() +echo getOccupiedMem() < 1024 |