[erlang-questions] Garbage Collection, BEAM memory and Erlang memory

Roberto Ostinelli roberto@REDACTED
Fri Jan 23 15:09:50 CET 2015

Hi Jesper, thank you for your input.

My hunch is you are holding on to binary values for too long in some
> processes, or are storing a ref-c binary in ETS which keeps the underlying
> binary alive. The two major ways to handle this has already been mentioned.

I'm not storing binaries in a ETS. Also, I don't see anywhere I'm holding
binary values for too long.

> If you are picking apart a large binary, and you need to reference
> *binary* data in it, then it may be beneficial to break that binary data
> off:
> <<Payload:Len/binary, "\r\n", Rest/binary>> = Packet,
> CPayload = binary:copy(Payload),
> ...
> recurse_on(Rest).
> but as Dan says, copying `Rest` in this case is a bad idea. You just copy
> the very binary you are running over and processing. Also note that it is
> important you are picking out binary data. If you had something like
> <<I:32/integer, "\r\n", Rest/binary>>
> then the integer conversion already excises the data from the binary, so
> you don't have to keep the binary around anymore.

Ok, as per this suggestion I removed copying the Rest.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150123/c462cfa1/attachment.htm>

More information about the erlang-questions mailing list