object pinning versus garbage collection
How does object pinning interact with garbage collection? Does it block garbage collection until it is manually unpinned? Or does it garbage collection proceed anyway? Intuitively I'd guess the former?? cheers -ben
Hi Ben,
On Sep 23, 2016, at 8:17 PM, Ben Coman <btc@openinworld.com> wrote:
How does object pinning interact with garbage collection? Does it block garbage collection until it is manually unpinned? Or does it garbage collection proceed anyway? Intuitively I'd guess the former??
The latter. The properties are orthogonal. Unreachable pinned objects are still unreachable. Therefore they are garbage collected. A use case that wishes to maintain a pinned object over some time period must arrange that there is a string reference to the object to define that time span.
cheers -ben
On Sun, Sep 25, 2016 at 7:14 AM, Eliot Miranda <eliot.miranda@gmail.com> wrote:
Hi Ben,
On Sep 23, 2016, at 8:17 PM, Ben Coman <btc@openinworld.com> wrote:
How does object pinning interact with garbage collection? Does it block garbage collection until it is manually unpinned? Or does it garbage collection proceed anyway? Intuitively I'd guess the former??
The latter. The properties are orthogonal. Unreachable pinned objects are still unreachable. Therefore they are garbage collected. A use case that wishes to maintain a pinned object over some time period must arrange that there is a string reference to the object to define that time span.
Thanks Eliot. So we need to be careful/aware of the corner case where an FFI callout function may store a reference to a pinned object past the return from the callout, and arrange things as you say. cheers -ben
participants (2)
-
Ben Coman -
Eliot Miranda