ARC: cycle detector (#12823)
* first implementation of the =trace and =dispose hooks for the cycle collector * a cycle collector for ARC: progress * manual: the .acyclic pragma is a thing once again * gcbench: adaptations for --gc:arc * enable valgrind tests for the strutils tests * testament: better valgrind support * ARC refactoring: growable jumpstacks * ARC cycle detector: non-recursive algorithm * moved and renamed core/ files back to system/ * refactoring: --gc:arc vs --gc:orc since 'orc' is even more experimental and we want to ship --gc:arc soonish
This commit is contained in:
parent
5848f0042c
commit
83a736a34a
45 changed files with 939 additions and 229 deletions
53
tests/destructor/tcycle1.nim
Normal file
53
tests/destructor/tcycle1.nim
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
discard """
|
||||
output: "MEM 0"
|
||||
cmd: "nim c --gc:orc $file"
|
||||
"""
|
||||
|
||||
type
|
||||
Node = ref object of RootObj
|
||||
le, ri: Node
|
||||
name: char
|
||||
|
||||
proc edge(a, b: Node) =
|
||||
if a.le == nil: a.le = b
|
||||
else: a.ri = b
|
||||
|
||||
proc createNode(name: char): Node =
|
||||
new result
|
||||
result.name = name
|
||||
|
||||
#[
|
||||
|
||||
+---------+ +------+
|
||||
| | | |
|
||||
| A +----->+ <------+-------------+
|
||||
+--+------+ | | | |
|
||||
| | | | C |
|
||||
| | R | | |
|
||||
+--v------+ | | +-------------+
|
||||
| | | | ^
|
||||
| B <------+ | |
|
||||
| | | +--------+
|
||||
+---------+ | |
|
||||
+------+
|
||||
|
||||
]#
|
||||
|
||||
proc main =
|
||||
let a = createNode('A')
|
||||
let b = createNode('B')
|
||||
let r = createNode('R')
|
||||
let c = createNode('C')
|
||||
|
||||
a.edge b
|
||||
a.edge r
|
||||
|
||||
r.edge b
|
||||
r.edge c
|
||||
|
||||
c.edge r
|
||||
|
||||
|
||||
let mem = getOccupiedMem()
|
||||
main()
|
||||
echo "MEM ", getOccupiedMem() - mem
|
||||
Loading…
Add table
Add a link
Reference in a new issue