mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 09:54:49 +00:00
* cycle collector: new implementation * cycle collector: make self-adaptive based on its previous effectiveness * cycle collector: added Lins's jump stack to improve traversal from 3*N to 2*N * cycle collector: make tests green * API extensions and bugfixes * code cleanup and use --gc:orc for tasyncawait
32 lines
500 B
Nim
32 lines
500 B
Nim
discard """
|
|
output: '''leak: false'''
|
|
cmd: '''nim c --gc:orc $file'''
|
|
"""
|
|
|
|
type
|
|
T = ref object
|
|
s: seq[T]
|
|
data: string
|
|
|
|
proc create(): T = T(s: @[], data: "abc")
|
|
|
|
proc addX(x: T; data: string) =
|
|
x.data = data
|
|
|
|
{.push sinkInference: off.}
|
|
|
|
proc addX(x: T; child: T) =
|
|
x.s.add child
|
|
|
|
{.pop.}
|
|
|
|
proc main(rootName: string) =
|
|
var root = create()
|
|
root.data = rootName
|
|
root.addX root
|
|
|
|
let mem = getOccupiedMem()
|
|
main("yeah")
|
|
GC_fullCollect()
|
|
echo "leak: ", getOccupiedMem() - mem > 0
|