tlists.nim 897 B

12345678910111213141516171819202122232425262728293031323334353637
  1. discard """
  2. output: '''Success'''
  3. retries: 2
  4. """
  5. # bug #3793
  6. import os
  7. import math
  8. import lists
  9. import strutils
  10. proc mkleak() =
  11. # allocate 1 MB via linked lists
  12. let numberOfLists = 100
  13. for i in countUp(1, numberOfLists):
  14. var leakList = initDoublyLinkedList[string]()
  15. let numberOfLeaks = 5000
  16. for j in countUp(1, numberOfLeaks):
  17. leakList.append(newString(200))
  18. proc mkManyLeaks() =
  19. for i in 0..0:
  20. when false: echo getOccupiedMem()
  21. mkleak()
  22. when false: echo getOccupiedMem()
  23. # Force a full collection. This should free all of the
  24. # lists and bring the memory usage down to a few MB's.
  25. GC_fullCollect()
  26. when false: echo getOccupiedMem()
  27. if getOccupiedMem() > 8 * 200 * 5000 * 2:
  28. echo GC_getStatistics()
  29. quit "leaking"
  30. echo "Success"
  31. mkManyLeaks()