gcleak.nim 434 B

1234567891011121314151617181920212223
  1. discard """
  2. outputsub: "no leak: "
  3. """
  4. when defined(GC_setMaxPause):
  5. GC_setMaxPause 2_000
  6. type
  7. TTestObj = object of RootObj
  8. x: string
  9. proc makeObj(): TTestObj =
  10. result.x = "Hello"
  11. for i in 1 .. 1_000_000:
  12. when defined(gcMarkAndSweep) or defined(boehmgc):
  13. GC_fullcollect()
  14. var obj = makeObj()
  15. if getOccupiedMem() > 300_000: quit("still a leak!")
  16. # echo GC_getstatistics()
  17. echo "no leak: ", getOccupiedMem()