[erlang-questions] Hidden binaries

Loïc Hoguin essen@REDACTED
Wed May 28 11:40:07 CEST 2014

On 05/28/2014 11:17 AM, Jesper Louis Andersen wrote:
> On Wed, May 28, 2014 at 10:26 AM, Lukas Larsson
> <lukas@REDACTED <mailto: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.

Actually, and correct me if I'm wrong, but the sub binary optimization 
breaks when you stick the identifier somewhere, so it ends up being 
copied automatically.

Loïc Hoguin

More information about the erlang-questions mailing list