tcycle2.nim 537 B

12345678910111213141516171819202122232425262728293031323334353637
  1. discard """
  2. output: "MEM 0"
  3. cmd: "nim c --gc:orc $file"
  4. """
  5. type
  6. Node = ref object
  7. kids: seq[Node]
  8. data: string
  9. proc main(x: int) =
  10. var n = Node(kids: @[], data: "3" & $x)
  11. let m = n
  12. n.kids.add m
  13. type
  14. NodeA = ref object
  15. s: char
  16. a: array[3, NodeA]
  17. proc m: NodeA =
  18. result = NodeA(s: 'a')
  19. result.a[0] = result
  20. result.a[1] = result
  21. result.a[2] = result
  22. proc mainA =
  23. for i in 0..10:
  24. discard m()
  25. let mem = getOccupiedMem()
  26. main(90)
  27. mainA()
  28. GC_fullCollect()
  29. echo "MEM ", getOccupiedMem() - mem