[Vm-dev] Object pinning vs. garbage collection

Eliot Miranda eliot.miranda at gmail.com
Wed Apr 27 17:38:50 UTC 2022

Hi Marcel,

On Wed, Apr 27, 2022 at 10:22 AM Marcel Taeumel <marcel.taeumel at hpi.de>

> 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.


> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20220427/e372f039/attachment.html>

More information about the Vm-dev mailing list