[erlang-questions] map over bitstring
Jesper Louis Andersen
Fri Oct 22 14:26:49 CEST 2010
On Fri, Oct 22, 2010 at 1:15 PM, Morten Krogh <> wrote:
> Hi Jesper
> Thanks for the link!
> It seems to me that the requirement that binaries must be contiguous in
> memory is quite strict.
> If that requirement was abandoned, binaries could be lists of ProcBins, or
> whatever they are called, instead.
This is essentially iolists you are proposing. They are already in the
for a quick discussion of them.
> Simple example from my module zip2
> Why is the memory usage 300 MB. It should have been 100MB, and in worst
> case, with naive copying, 200MB.
> But 300 MB.
My guess is that B has some excess space allocated for appending which
amount to around 100Mb (you should probably not go with a 100Mb binary
in the first place, but rather an iolist of smaller binaries). B's
extra space will only get shrunk away when the runtime decide to
transfer the binary to another process and it is not before it is sent
back to the shell as a message.
My guess might be wrong though.
More information about the erlang-questions