diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-12-05 23:15:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-05 23:15:17 +0100 |
commit | af7f7726fe727b68238533f690fb7cd98552e4e4 (patch) | |
tree | e0621ef74aa7cbdb554637185d45149f3d1727b2 /tests | |
parent | 70d4df051648771269251cca8b4a6aa32ae636d0 (diff) | |
download | Nim-af7f7726fe727b68238533f690fb7cd98552e4e4.tar.gz |
ORC: make the adaptive strategy the default in order to fight memory consumption (#16250)
* ORC: make the adaptive strategy the default in order to fight memory consumption * added missing test case
Diffstat (limited to 'tests')
-rw-r--r-- | tests/arc/tasyncleak.nim | 2 | ||||
-rw-r--r-- | tests/arc/torcbench.nim | 38 |
2 files changed, 39 insertions, 1 deletions
diff --git a/tests/arc/tasyncleak.nim b/tests/arc/tasyncleak.nim index 417b67edb..eb0c45213 100644 --- a/tests/arc/tasyncleak.nim +++ b/tests/arc/tasyncleak.nim @@ -1,5 +1,5 @@ discard """ - outputsub: "(allocCount: 4014, deallocCount: 4012)" + outputsub: "(allocCount: 4302, deallocCount: 4300)" cmd: "nim c --gc:orc -d:nimAllocStats $file" """ diff --git a/tests/arc/torcbench.nim b/tests/arc/torcbench.nim new file mode 100644 index 000000000..4c9e65fee --- /dev/null +++ b/tests/arc/torcbench.nim @@ -0,0 +1,38 @@ +discard """ + output: '''true peak memory: true''' + cmd: "nim c --gc:orc -d:release $file" +""" + +import lists, strutils, times + +type + Base = ref object of RootObj + + Node = ref object of Base + parent: DoublyLinkedList[string] + le, ri: Node + self: Node # in order to create a cycle + +proc buildTree(parent: DoublyLinkedList[string]; depth: int): Node = + if depth == 0: + result = nil + elif depth == 1: + result = Node(parent: parent, le: nil, ri: nil, self: nil) + when not defined(gcArc): + result.self = result + else: + result = Node(parent: parent, le: buildTree(parent, depth - 1), ri: buildTree(parent, depth - 2), self: nil) + result.self = result + +proc main() = + for i in countup(1, 100): + var leakList = initDoublyLinkedList[string]() + for j in countup(1, 5000): + leakList.append(newString(200)) + #GC_fullCollect() + for i in 0..400: + discard buildTree(leakList, 8) + +main() +GC_fullCollect() +echo getOccupiedMem() < 10 * 1024 * 1024, " peak memory: ", getMaxMem() < 10 * 1024 * 1024 |