mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 19:52:36 +00:00
Fixes #23212
Inspired by [this chronos
PR](https://github.com/status-im/nim-chronos/pull/243)
(cherry picked from commit f29234b40f)
29 lines
493 B
Nim
29 lines
493 B
Nim
discard """
|
|
valgrind: true
|
|
cmd: '''nim c --mm:arc -d:nimAllocStats -d:useMalloc $file'''
|
|
output: '''1000'''
|
|
"""
|
|
|
|
import std/asyncdispatch
|
|
|
|
var count: int
|
|
|
|
proc stuff() {.async.} =
|
|
#echo count, 1
|
|
await sleepAsync(1)
|
|
#echo count, 2
|
|
count.inc
|
|
|
|
for _ in 0..<1000:
|
|
asyncCheck stuff()
|
|
|
|
while hasPendingOperations(): poll()
|
|
|
|
echo count
|
|
|
|
setGlobalDispatcher(nil)
|
|
|
|
import std/importutils
|
|
privateAccess(AllocStats)
|
|
doAssert getAllocStats().allocCount - getAllocStats().deallocCount < 10
|