[erlang-questions] Removing eterm from NifEnv.

Lukas Larsson lukas@REDACTED
Mon Nov 20 08:05:15 CET 2017


Hello,

On Sat, Nov 18, 2017 at 8:20 PM, Ilya Khaprov <ilya.khaprov@REDACTED>
wrote:

> I copy (enif_make_copy) an eterm to private NifEnv inside Nif.
>
> Later I want to remove that eterm from the NifEnv (actually I want to free
> memory, but I guess this means removing from NifEnv’s heap).
>
> How to do this? I know about enif_free_env, but this function clear entire
> env.
>

It is not possible to free an individual term from a nif environment. If
you want to have that kind of granularity, you have to create one
environment per term that you want to individually collect. If the
allocation cost of a new env is too large for your application, you could
pool env's and use enif_clear_env to re-cycle env's into the pool.

Lukas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20171120/bb29c2b8/attachment.htm>


More information about the erlang-questions mailing list