trace_globals.nim 768 B

12345678910111213141516171819202122232425262728293031323334
  1. discard """
  2. output: '''
  3. 10000000
  4. 10000000
  5. 10000000'''
  6. """
  7. # bug #17085
  8. #[
  9. refs https://github.com/nim-lang/Nim/issues/17085#issuecomment-786466595
  10. with --gc:boehm, this warning sometimes gets generated:
  11. Warning: Repeated allocation of very large block (appr. size 14880768):
  12. May lead to memory leak and poor performance.
  13. nim CI now runs this test with `testWithoutBoehm` to avoid running it with --gc:boehm.
  14. ]#
  15. proc init(): string =
  16. for a in 0..<10000000:
  17. result.add 'c'
  18. proc f() =
  19. var a {.global.} = init()
  20. var b {.global.} = init()
  21. var c {.global.} = init()
  22. echo a.len
  23. # `echo` intentional according to
  24. # https://github.com/nim-lang/Nim/pull/17469/files/0c9e94cb6b9ebca9da7cb19a063fba7aa409748e#r600016573
  25. echo b.len
  26. echo c.len
  27. f()