[erlang-questions] Am I leaking memory inside my linked in driver?
Tue Feb 26 14:01:46 CET 2013
On 2/26/2013 12:52 AM, Zabrane Mickael wrote:
> Final question: is it better in term of performances to use
> "driver_mk_atom("ok");" instead?
> I mean, declare all my atoms (as static variables) once at the beginning
> and use their references.
> No need for me to deallocate anything in that case, right?
The ei_x_encode_atom() and driver_mk_atom() serve different purposes.
The first one encodes a string into external Erlang binary format given
a string representation of the atom (i.e. serializes it in a wire-level
format to be sent elsewhere). It is to be used to assist with
communicating with Erlang in a port program running in a separate
process, and in a driver using the "output" callback function.
The second one driver_mk_atom() is used in drivers that run in the
address space of the emulator to create atoms by the emulator.
So the answer to your question depends on what it is that you are
writing. If you are writing a driver, then yes, use driver_mk_atom()
and you don't need to deallocate anything - atoms are global and not
If you are writing a port program, then driver_mk_atom() has no meaning
for a port program, and is not part of exported ei interface, so you
can't use it.
More information about the erlang-questions