[erlang-questions] Why avoid calling enif_make_atom?
Loïc Hoguin
essen@REDACTED
Thu Feb 23 12:08:35 CET 2017
An example from OTP itself:
https://github.com/erlang/otp/blob/master/erts/emulator/nifs/common/erl_tracer_nif.c#L54
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
> https://github.com/davisp/nif-examples/blob/master/apps/termsend/c_src/termsend.c#L4,
> 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
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
--
Loïc Hoguin
https://ninenines.eu
More information about the erlang-questions
mailing list