t23212.nim 493 B

1234567891011121314151617181920212223242526272829
  1. discard """
  2. valgrind: true
  3. cmd: '''nim c --mm:arc -d:nimAllocStats -d:useMalloc $file'''
  4. output: '''1000'''
  5. """
  6. import std/asyncdispatch
  7. var count: int
  8. proc stuff() {.async.} =
  9. #echo count, 1
  10. await sleepAsync(1)
  11. #echo count, 2
  12. count.inc
  13. for _ in 0..<1000:
  14. asyncCheck stuff()
  15. while hasPendingOperations(): poll()
  16. echo count
  17. setGlobalDispatcher(nil)
  18. import std/importutils
  19. privateAccess(AllocStats)
  20. doAssert getAllocStats().allocCount - getAllocStats().deallocCount < 10