object pinning versus garbage collection

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

object pinning versus garbage collection

Ben Coman
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

Reply | Threaded
Open this post in threaded view
|

Re: object pinning versus garbage collection

Eliot Miranda-2
Hi Ben,

> On Sep 23, 2016, at 8:17 PM, Ben Coman <[hidden email]> 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
>

Reply | Threaded
Open this post in threaded view
|

Re: object pinning versus garbage collection

Ben Coman
On Sun, Sep 25, 2016 at 7:14 AM, Eliot Miranda <[hidden email]> wrote:
> Hi Ben,
>
>> On Sep 23, 2016, at 8:17 PM, Ben Coman <[hidden email]> 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