[erlang-questions] Why avoid calling enif_make_atom?
Thu Feb 23 12:08:35 CET 2017
An example from OTP itself:
I think it's more an optimization. Call the function only once on load
and then use the static variables directly.
On 02/23/2017 12:04 PM, Roger Lipscombe wrote:
> All of the NIF-using Erlang projects I've found seem to allocate their
> atoms during load. Some examples:
> - jiffy: https://github.com/davisp/jiffy/blob/master/c_src/jiffy.c
> - re2: https://github.com/tuncer/re2/blob/master/c_src/re2_nif.cpp#L180
> I also found some skeleton NIF code, at
> that checks enif_make_existing_atom first.
> I guess my question is:
> What's the harm in calling enif_make_atom whenever I need an atom
> term? Does it leak atoms?
> erlang-questions mailing list
More information about the erlang-questions