[erlang-questions] enif_free and free in a NIF

Matthew Evans mattevans123@REDACTED
Fri Jul 4 02:16:12 CEST 2014

I actually just found the cause of the crash. We had gen_server "A" that loaded the NIF, but we also had another gen_server directly calling a nif function owned by gen_server "A" instead of doing a gen_server:call to "A".

Date: Fri, 4 Jul 2014 00:06:22 +0200
Subject: Re: [erlang-questions] enif_free and free in a NIF
From: lukas@REDACTED
To: mattevans123@REDACTED
CC: erlang-questions@REDACTED


On Thu, Jul 3, 2014 at 9:45 PM, Matthew Evans <mattevans123@REDACTED> wrote:

The question is is it safe to mix and match the Erlang memory allocation/deallocation NIF libraries with the standard Linux calls to free and malloc?

Depends on what you mean by mix and match. It is ok to allocate with both malloc and enif_alloc in a nif as long as you deallocate with free and enif_free respectively. It does not work to allocate with enif_alloc and then deallocate with free.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140703/9566643f/attachment.htm>

More information about the erlang-questions mailing list