gcleak3.nim 441 B

123456789101112131415161718192021222324252627
  1. discard """
  2. outputsub: "no leak: "
  3. """
  4. when defined(GC_setMaxPause):
  5. GC_setMaxPause 2_000
  6. type
  7. TSomething = object
  8. s: string
  9. s1: string
  10. var s: seq[TSomething] = @[]
  11. for i in 0..1024:
  12. var obj: TSomething
  13. obj.s = "blah"
  14. obj.s1 = "asd"
  15. s.add(obj)
  16. proc limit*[t](a: var seq[t]) =
  17. while s.len > 0:
  18. if getOccupiedMem() > 3000_000: quit("still a leak!")
  19. s.delete(0)
  20. s.limit()
  21. echo "no leak: ", getOccupiedMem()