You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ideally, closures should not hold any kind of reference to GObjects. C code doesn't do this: there's no capturing, and closures all take and release references as they're called instead of holding a reference for as long as the object is alive.
Currently, Go's finalizer fails us. Ou closures reference objects throughout the duration of the program, causing a finalizer cycle. This Can we make the finalizer do less and do our work in the toggle notifier?
Proposal
Go should hold a strong or weak reference to the object; the finalizer unrefs it
We'll handle freeing the object using a C-based toggle notifier
Can we get away with using WeakRefs for the Go object? Is there a way to combine both that and the Go finalizer to detect when to actually free?
The text was updated successfully, but these errors were encountered:
An interesting alternative would be to make objects floating/weak by default. Users who want to revive a GObject later on must manually sink the reference with .Sink() or be extra careful with how they take the object away from C memory.
If we do this, how would subclassed objects work? We would have to keep a Go reference. This might overcomplicate things.
Preamble
Ideally, closures should not hold any kind of reference to GObjects. C code doesn't do this: there's no capturing, and closures all take and release references as they're called instead of holding a reference for as long as the object is alive.
Currently, Go's finalizer fails us. Ou closures reference objects throughout the duration of the program, causing a finalizer cycle. This Can we make the finalizer do less and do our work in the toggle notifier?
Proposal
Can we get away with using WeakRefs for the Go object? Is there a way to combine both that and the Go finalizer to detect when to actually free?
The text was updated successfully, but these errors were encountered: