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

when defined(GC_setMaxPause):
  GC_setMaxPause 2_000

type
  TTestObj = object of RootObj
    x: string

proc makeObj(): TTestObj =
  result.x = "Hello"

for i in 1 .. 100_000:
  when defined(gcMarkAndSweep) or defined(boehmgc):
    GC_fullcollect()
  var obj = makeObj()
  if getOccupiedMem() > 300_000: quit("still a leak!")
#  echo GC_getstatistics()

echo "no leak: ", getOccupiedMem()