gcleak3.nim 454 B

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