[erlang-questions] Binaries

Bob Ippolito bob@REDACTED
Thu Mar 3 22:21:02 CET 2011


Large binaries are reference counted.

1> byte_size(term_to_binary(1.0)).
33
2> byte_size(term_to_binary(1.0, [{minor_version, 1}])).
10
3> byte_size(<<1.0/float>>).
8

On Thu, Mar 3, 2011 at 11:56 AM, Bob Cowdery <bob@REDACTED> wrote:
> One of the things I need to do is move large binaries of up to 4096
> floats around between processes. As there are real-time constraints on
> processing this data I just wanted to check a few things.
>
> The docs say that large binaries are zero copy (presumable only in the
> same node). How exactly does this work in a lock free environment?
>
> 1> T=[1.0].
> [1.0]
> 2> B=term_to_binary(T).
> <<131,108,0,0,0,1,99,49,46,48,48,48,48,48,48,48,48,48,48,
>  48,48,48,48,48,48,48,48,48,48,...>>
> 3> size(B).
> 39
>
> The docs also say that binary data is efficient. Why does 1 float
> convert to 39 bytes? This ratio only reduces slightly with larger lists
> . If erlang holds floats internally in 64 bit format I don't understand
> why it needs 39 bytes.
>
> Bob
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>


More information about the erlang-questions mailing list