mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 17:34:43 +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)
40 lines
616 B
Nim
40 lines
616 B
Nim
discard """
|
|
outputsub: "no leak: "
|
|
"""
|
|
|
|
type
|
|
TNode = object
|
|
data: array[0..300, char]
|
|
|
|
PNode = ref TNode
|
|
|
|
TNodeArray = array[0..10, PNode]
|
|
|
|
TArrayHolder = object
|
|
sons: TNodeArray
|
|
|
|
proc nullify(a: var TNodeArray) =
|
|
for i in 0..high(a):
|
|
a[i] = nil
|
|
|
|
proc newArrayHolder: ref TArrayHolder =
|
|
new result
|
|
|
|
for i in 0..high(result.sons):
|
|
new result.sons[i]
|
|
|
|
nullify result.sons
|
|
|
|
proc loop =
|
|
for i in 0..10000:
|
|
discard newArrayHolder()
|
|
|
|
if getOccupiedMem() > 300_000:
|
|
echo "still a leak! ", getOccupiedMem()
|
|
quit 1
|
|
else:
|
|
echo "no leak: ", getOccupiedMem()
|
|
|
|
loop()
|
|
|