I've extended the experiment to --gc:refc, this also is giving me some unexpected results: finalizers seems never called even after GC_fullCollect()
Compile with --gc:refc const n = 0 when n == 0: # RootObj + forward declaration # Custom finalizer not called type Foo = ref object of RootObj proc delete(self: Foo) proc newFoo: Foo = new(result, delete) proc delete(self: Foo) = echo("delete Foo") when n == 1: # RootObj + no forward declaration # Custom finalizer not called type Foo = ref object of RootObj proc delete(self: Foo) = echo("delete Foo") proc newFoo: Foo = new(result, delete) when n == 2: # no RootObj + forward declaration # Custom finalizer not called type Foo = ref object proc delete(self: Foo) proc newFoo: Foo = new(result, delete) proc delete(self: Foo) = echo("delete Foo") when n == 3: # no RootObj + no forward declaration # Custom finalizer not called type Foo = ref object proc delete(self: Foo) = echo("delete Foo") proc newFoo: Foo = new(result, delete) if isMainModule: discard newFoo() GC_fullCollect() Run