Files
Nim/tests/async/t23212.nim
Esteban C Borsani ede6540c55 fixes #23212; Asyncdispatch leaks under --mm:arc (#24556)
Fixes #23212

Inspired by [this chronos
PR](https://github.com/status-im/nim-chronos/pull/243)

(cherry picked from commit f29234b40f)
2025-01-15 10:19:26 +01:00

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