tgc.nim 624 B

1234567891011121314151617181920212223
  1. discard """
  2. matrix: "--gc:refc; --gc:arc; --gc:orc"
  3. targets: "c"
  4. """
  5. when compileOption("gc", "refc") or not defined(openbsd):
  6. # xxx openbsd gave: stdlib_coro.nim.c:406:22: error: array type 'jmp_buf' (aka 'long [11]') is not assignable (*dest).execContext = src.execContext;
  7. import coro
  8. var maxOccupiedMemory = 0
  9. proc testGC() =
  10. var numbers = newSeq[int](100)
  11. maxOccupiedMemory = max(maxOccupiedMemory, getOccupiedMem())
  12. suspend(0)
  13. start(testGC)
  14. start(testGC)
  15. run()
  16. GC_fullCollect()
  17. doAssert(getOccupiedMem() < maxOccupiedMemory, "GC did not free any memory allocated in coroutines")