OK, that is what I guessed more or less...
I think I will try to put all the relevant code into another proc and then call
GC_fullCollect() when that proc is finished, then all stack of that proc should
be released and finalizer should be called for that objects. Will continue
testing GTK3 GC
Sounds like you measure stale references on the stack that can keep things
alive. In more realistic settings the stack is reused heavily and the GC can
collect.
Well, here is a self contained example:
type
O1 = ref object of RootObj
i: int
O2 = ref object of O1
j: int
proc finalizeGObject*[T](o: T) =
echo "finalizeGObject"
#proc xadd(self: O1; widget: O2) =
# discard
When I modify the xadd() proc to
proc xadd(self: Container; widget: Button) =
discard
then finalizer is called again!
So problem is, that Button is a Widget which is again a GObject...
Which results for the initial code to
> T4_ = >Sup.Sup.Sup;
>
I tried to test for memory leaks of the high level GTK3 bindings.
import gtk, glib, gobject
proc initWithArgv*() =
var
cmdLine{.importc.}: cstringArray
cmdCount{.importc.}: cint
gtk.gtk_init(cmdCount, cmdLine)
proc xadd*(self: Container;