[erlang-questions] Removing eterm from NifEnv.

Ilya Khaprov ilya.khaprov@REDACTED
Tue Nov 21 11:03:31 CET 2017


Thanks! I think I can group my terms to reduce allocations/garbage collections.

Best regards,
Ilya

________________________________
From: Lukas Larsson <lukas@REDACTED>
Sent: Monday, November 20, 2017 10:05:15 AM
To: Ilya Khaprov
Cc: Erlang Questions
Subject: Re: [erlang-questions] Removing eterm from NifEnv.

Hello,

On Sat, Nov 18, 2017 at 8:20 PM, Ilya Khaprov <ilya.khaprov@REDACTED<mailto: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/20171121/ee593b6c/attachment.htm>


More information about the erlang-questions mailing list