[erlang-questions] Safe way to cache atoms in NIF: driver_mk_atom replacement
Fri May 4 16:11:01 CEST 2012
Currently atoms are independent of environment (ErlNifEnv). That is, you
can cache atoms by storing them in static variables as done in crypto.c.
This is an undocumented feature however.
To compensate for future possible introduction of atom-GC I have thought
of documenting this feature with some restriction. Something like
"Atoms created in load/upgrade callbacks are static and can be used in
Lukas Larsson wrote:
> If I understand you correctly the answer is yes.
> I think the crypto implementation does exactly this and since
> Sverker wrote both crypto and the NIF support I would say that it is
> safe :)
>  https://github.com/erlang/otp/blob/maint/lib/crypto/c_src/crypto.c#L300
> On Fri, May 4, 2012 at 3:22 PM, Max Lapshin <> wrote:
>> Is there a way to cache atoms in NIF?
>> Is it ok just to store in static variable result of enif_make_atom ?
>> erlang-questions mailing list
> erlang-questions mailing list
More information about the erlang-questions