gcleak2.nim 498 B

123456789101112131415161718192021222324252627
  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. s: seq[int]
  10. proc makeObj(): TTestObj =
  11. result.x = "Hello"
  12. result.s = @[1,2,3]
  13. proc inProc() =
  14. for i in 1 .. 1_000_000:
  15. when defined(gcMarkAndSweep) or defined(boehmgc):
  16. GC_fullcollect()
  17. var obj: TTestObj
  18. obj = makeObj()
  19. if getOccupiedMem() > 300_000: quit("still a leak!")
  20. inProc()
  21. echo "no leak: ", getOccupiedMem()