[erlang-questions] Hidden binaries

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Wed May 28 11:17:03 CEST 2014


On Wed, May 28, 2014 at 10:26 AM, Lukas Larsson
<lukas@REDACTED>wrote:

> 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.


-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140528/c09c7c64/attachment.htm>


More information about the erlang-questions mailing list