diff --git a/lib/system/orc.nim b/lib/system/orc.nim index 1935407102..b7b98c3404 100644 --- a/lib/system/orc.nim +++ b/lib/system/orc.nim @@ -411,7 +411,7 @@ proc registerCycle(s: Cell; desc: PNimTypeV2) = if roots.d == nil: init(roots) add(roots, s, desc) - if roots.len >= rootsThreshold+defaultThreshold: + if roots.len - defaultThreshold >= rootsThreshold: collectCycles() when logOrc: writeCell("[added root]", s, desc) diff --git a/tests/gc/tdisable_orc.nim b/tests/gc/tdisable_orc.nim new file mode 100644 index 0000000000..b5f161c791 --- /dev/null +++ b/tests/gc/tdisable_orc.nim @@ -0,0 +1,9 @@ +discard """ + joinable: false +""" + +import std/asyncdispatch + +# bug #22256 +GC_disableMarkAndSweep() +waitFor sleepAsync(1000)