cyclecollector.nim 390 B

12345678910111213141516171819202122
  1. # Program to detect bug #1796 reliably
  2. type
  3. Node = ref object
  4. a, b: Node
  5. leaf: string
  6. proc createCycle(leaf: string): Node =
  7. new result
  8. result.a = result
  9. shallowCopy result.leaf, leaf
  10. proc main =
  11. for i in 0 .. 100_000:
  12. var leaf = "this is the leaf. it allocates"
  13. let x = createCycle(leaf)
  14. let y = createCycle(leaf)
  15. echo "done ", getOccupiedMem()
  16. main()