summary refs log tree commit diff stats
path: root/tests/gc/gcleak2.nim
blob: a50541fbcad957c3a5aff86ee72ce898f6fbd925 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
discard """
  outputsub: "no leak: "
"""

when defined(GC_setMaxPause):
  GC_setMaxPause 2_000

type
  TTestObj = object of TObject
    x: string
    s: seq[int]

proc MakeObj(): TTestObj =
  result.x = "Hello"
  result.s = @[1,2,3]

proc inProc() = 
  for i in 1 .. 100_000_000:
    var obj: TTestObj
    obj = MakeObj()
    if getOccupiedMem() > 300_000: quit("still a leak!")

inProc()
echo "no leak: ", getOccupiedMem()