[erlang-questions] Hidden binaries
Jesper Louis Andersen
Wed May 28 11:17:03 CEST 2014
On Wed, May 28, 2014 at 10:26 AM, Lukas Larsson
> Binaries can also be present in ets objects and messages in processes'
> message queues. I'm sure there are some other places as well, but those
> should be the major ones.
This is a common case. Say you have a binary of size 1024 bytes and you
pick out an identifier in it which is 8 bytes. The identifier is now a
sub-binary which keeps the large binary around. If you stick the identifier
somewhere, you will be "wasting" 1024-8 bytes.
The solution is to explicitly put a binary:copy/1 in place to "lift out"
the small identifier.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions