[erlang-questions] Erlang and Memory management

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Thu Jun 2 11:33:11 CEST 2011

On Thu, Jun 2, 2011 at 10:53, Wenqiang Song <wsong.cn@REDACTED> wrote:
> A related question, for code like following:
> test(<<255, T/binary>>) ->
>     ok;
> test(<<_, T/binary>>) ->
>     test(T).
> Does Erlang copy the input binary for each recursion? If the input is huge,
> it would be very low efficient. If so, what should we do?

No. It just has a pointer into the existing binary. Immutability is nice :)


is the source you want to look at. Compile your code with the
bin_opt_info flag to see if optimizations trigger as well.


More information about the erlang-questions mailing list