[erlang-questions] Hint erts to preallocate binary of required size

Dmitry Kolesnikov <>
Fri Feb 22 20:18:57 CET 2013


Hello Max,

> First problem: how can I understand if process copies these small chunks into heap or they are still subbinary?

http://erldocs.com/R14B02/stdlib/binary.html?i=25&search=binary:#referenced_byte_size/1

> Second idea: can it be a good idea to tell erts that I want to allocate new binary of 140 kbytes size and append small chunks to it with only one copying?

May be you should use iolist instead of binary?

- Dmitry

On Feb 22, 2013, at 9:09 PM, Max Lapshin <> wrote:

> erlyvideo has some problems with creating mpeg-ts from mp4.
> 
> Problem is following: mp4 stores video frames in continuos blocks of 100 kbytes. MPEG-TS requires to split this 100 kbytes into small chunks of about 180 bytes each.
> 
> Right now it takes about 10 000 microseconds to generate one megabyte of mpeg-ts.
> 
> First problem: how can I understand if process copies these small chunks into heap or they are still subbinary?
> 
> 
> Second idea: can it be a good idea to tell erts that I want to allocate new binary of 140 kbytes size and append small chunks to it with only one copying?
> 
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list