[erlang-questions] Why avoid calling enif_make_atom?

Roger Lipscombe roger@REDACTED
Thu Feb 23 12:04:23 CET 2017


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?



More information about the erlang-questions mailing list