<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Thanks,<div><br></div><div>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".<br><br><div><hr id="stopSpelling">Date: Fri, 4 Jul 2014 00:06:22 +0200<br>Subject: Re: [erlang-questions] enif_free and free in a NIF<br>From: lukas@erlang.org<br>To: mattevans123@hotmail.com<br>CC: erlang-questions@erlang.org<br><br><div dir="ltr">Hello,<br><div class="ecxgmail_extra"><br><div class="ecxgmail_quote">On Thu, Jul 3, 2014 at 9:45 PM, Matthew Evans <span dir="ltr"><<a href="mailto:mattevans123@hotmail.com" target="_blank">mattevans123@hotmail.com</a>></span> wrote:<br>
<blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex;">


<div><div dir="ltr"><div><br></div><div>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?</div><div><br></div></div></div>
</blockquote><div><br></div><div>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.</div>
<div><br></div><div>Lukas</div></div></div></div></div></div>                                         </div></body>
</html>