[erlang-questions] nif resources

Rapsey <>
Thu Jun 24 10:56:11 CEST 2010


On Thu, Jun 24, 2010 at 10:45 AM, Sverker Eriksson <
> wrote:

> Rapsey wrote:
>
>> If a resource was created within a thread (and released with
>> enif_release_resource), then sent to some erlang process. Will that erlang
>> process have a handle to the resource (thus prevent it from being
>> released)
>> even if it did not save it anywhere (the variable for the resource was
>> ignored)?
>> This is the behavior I am seeing. Unless I kill the process which received
>> the resource, it will never get released. Is there any way to make an
>> erlang
>> process release it's handle to the resource?
>> I'm using R14A
>>
>>
> A resource that is not references by any Erlang process and totally
> released with enif_release_resource
> should eventually be garbage collected like any other term.
>
> Have you tried erlang:garbage_collect when verifying if the destructor is
> called?
>
> /Sverker, Erlang/OTP
>
>
I played around with it just now, I guess my test method was too simple. The
process has to get called a few times for the resource to be cleared by the
GC (without needing to explicitly call garbage_collect). If it just sits
there after the last message, resource will not get released.
Thanks.


Sergej


More information about the erlang-questions mailing list