.cursor implementation (#12637)
* cursors: first implementation * added currently failing test * .cursor works for doubly linked lists * make -d:useMalloc work again * added code to nil out refs in a destructor * it's now called --gc:arc * renderer.nim: render nkBreakState properly * make simple closure iterators work without leaking
This commit is contained in:
parent
7e689873e2
commit
dfb020b174
12 changed files with 106 additions and 36 deletions
38
tests/destructor/tlists.nim
Normal file
38
tests/destructor/tlists.nim
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
discard """
|
||||
output: '''Success
|
||||
@["a", "b", "c"]
|
||||
0'''
|
||||
cmd: '''nim c --gc:destructors $file'''
|
||||
"""
|
||||
|
||||
import os
|
||||
import math
|
||||
import lists
|
||||
import strutils
|
||||
|
||||
proc mkleak() =
|
||||
# allocate 1 MB via linked lists
|
||||
let numberOfLists = 100
|
||||
for i in countUp(1, numberOfLists):
|
||||
var leakList = initDoublyLinkedList[string]()
|
||||
let numberOfLeaks = 5000
|
||||
for j in countUp(1, numberOfLeaks):
|
||||
leakList.append(newString(200))
|
||||
|
||||
proc mkManyLeaks() =
|
||||
for i in 0..0:
|
||||
mkleak()
|
||||
echo "Success"
|
||||
|
||||
iterator foobar(c: string): seq[string] {.closure.} =
|
||||
yield @["a", "b", c]
|
||||
|
||||
proc tsimpleClosureIterator =
|
||||
var myc = "c"
|
||||
for it in foobar(myc):
|
||||
echo it
|
||||
|
||||
let startMem = getOccupiedMem()
|
||||
mkManyLeaks()
|
||||
tsimpleClosureIterator()
|
||||
echo getOccupiedMem() - startMem
|
||||
Loading…
Add table
Add a link
Reference in a new issue