mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 09:24:36 +00:00
This revision is intended as comparison point between the old and the new GC The used GC can be switched in mmdisp and various statistics will be gathered during execution (these will be removed/disabled in later revisions)
32 lines
493 B
Nim
32 lines
493 B
Nim
discard """
|
|
outputsub: "no leak: "
|
|
"""
|
|
|
|
type
|
|
Cyclic = object
|
|
sibling: PCyclic
|
|
data: array[0..200, char]
|
|
|
|
PCyclic = ref Cyclic
|
|
|
|
proc makePair: PCyclic =
|
|
new(result)
|
|
new(result.sibling)
|
|
result.sibling.sibling = result
|
|
|
|
proc loop =
|
|
for i in 0..10000:
|
|
var x = makePair()
|
|
GC_fullCollect()
|
|
x = nil
|
|
GC_fullCollect()
|
|
|
|
if getOccupiedMem() > 300_000:
|
|
echo "still a leak! ", getOccupiedMem()
|
|
quit(1)
|
|
else:
|
|
echo "no leak: ", getOccupiedMem()
|
|
|
|
loop()
|
|
|