[erlang-questions] Managing object lifetimes from NIF

Gregory Haskins <>
Wed May 25 22:46:54 CEST 2011

Hi All,

Is it possible to safely retain references to objects like an
ERL_NIF_TERM inside a NIF resource?

For instance, can I have

struct myresource {
	ErlNifPid *pid;
	ERL_NIF_TERM *term;

and allocate this structure with enif_alloc_resource in such a way that
I can ensure (either implicitly or explictly) that pid/term are properly
reference counted till at least the dtor is called on my resource?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 267 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110525/c147ecee/attachment.bin>

More information about the erlang-questions mailing list