[erlang-questions] binary:copy before sending message, or after receiving it?

Roger Lipscombe roger@REDACTED
Wed Dec 20 16:00:38 CET 2017


I've got a piece of code that's run from a long-lived, but not
particularly memory-heavy process. It looks like this:

    JSON = jiffy:encode(SomeMap),
    gen_server:cast(Server, {append, JSON}).

I suspect that this is causing a bunch of fragmentation of the binary
heap. Should I be calling binary:copy(JSON) before I send the message,
in this process? Or should I be calling binary:copy in the receiving
gen_server? Or doesn't it matter, as long as one of them does it?



More information about the erlang-questions mailing list