fixes the recently discovered GC memory leaks
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)
This commit is contained in:
parent
d0edb1826b
commit
083d4f4708
12 changed files with 1939 additions and 364 deletions
39
tests/gc/refarrayleak.nim
Normal file
39
tests/gc/refarrayleak.nim
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
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()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue