diff options
author | Araq <rumpf_a@web.de> | 2012-11-22 21:37:01 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-11-22 21:37:01 +0100 |
commit | 4bef5a7a78981bc8f5b8b3bd3f8c1c9de8533bb5 (patch) | |
tree | a5537012fc9d5d64359bf1e3fca24ef5fba0ff21 /tests/gc/stackrefleak.nim | |
parent | f610d2d2217b757901929ed92725a1b682e1165c (diff) | |
parent | ad53e0b022cb50bc069cfb9d196c3a11b4205b44 (diff) | |
download | Nim-4bef5a7a78981bc8f5b8b3bd3f8c1c9de8533bb5.tar.gz |
Merge branch 'master' of github.com:Araq/Nimrod
Diffstat (limited to 'tests/gc/stackrefleak.nim')
-rw-r--r-- | tests/gc/stackrefleak.nim | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/gc/stackrefleak.nim b/tests/gc/stackrefleak.nim new file mode 100644 index 000000000..2c652d6bf --- /dev/null +++ b/tests/gc/stackrefleak.nim @@ -0,0 +1,33 @@ +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() + + + |