Hi Eliot, hi all --
Can a pinned object get garbage collected at all? Do I have to ensure to have at least a single reference to that (pinned) object?
My best answer would be: Yes. Otherwise, I could never get rid of that pinned object again.
This has interesting implications also for an FFI programming interface. If you send out a pointer to object memory everything is fine if (a) that object is pinned an (b) that object does not get garbage collected. Pinning is easy. Keeping track of an object that gets collected but is actually pinned should raise a warning ... I suppose. Hmm...
Best, Marcel
Hi Marcel,
On Wed, Apr 27, 2022 at 10:22 AM Marcel Taeumel marcel.taeumel@hpi.de wrote:
Hi Eliot, hi all --
Can a pinned object get garbage collected at all? Do I have to ensure to have at least a single reference to that (pinned) object?
Yes and yes.
My best answer would be: Yes. Otherwise, I could never get rid of that pinned object again.
Indeed.
This has interesting implications also for an FFI programming interface. If you send out a pointer to object memory everything is fine if (a) that object is pinned an (b) that object does not get garbage collected. Pinning is easy. Keeping track of an object that gets collected but is actually pinned should raise a warning ... I suppose. Hmm...
This has always been the case (and in all Smalltalks with which I'm familiar). It is orthogonal to the pinning issue. Any object passed to external code must be registered and managed manually for the duration of its external use to prevent it being prematurely collected, since the GC tracks only internal references to objects.
Note that at the FFI/plugin level the VM offers addGCRoot & removeGCRoot for use by external and plugin code to do the management itself.
_,,,^..^,,,_ best, Eliot
vm-dev@lists.squeakfoundation.org