[erlang-questions] Garbage collecting binaries

Bob Ippolito bob@REDACTED
Sat Oct 9 09:42:02 CEST 2010


On Sat, Oct 9, 2010 at 3:28 PM, Masklinn <masklinn@REDACTED> wrote:
> On 9 oct. 2010, at 00:34, Scott Lystig Fritchie <fritchie@REDACTED> wrote:
>> Tom, one other thing to keep in mind ... if you pull in a huge binary,
>> and then use pattern matching to "pick apart" that binary, the pattern
>> matching is likely to create sub-binaries that still reference the
>> original.  So then the chain of who's got a reference to the huge binary
>> gets more difficult to untangle: if you keep the small sub-binary around
>> forever (e.g. as part of a long-lived process's state), then you'll keep
>> the underlying "heap" binary around forever also.
>>
>> -Scott
> On that subject, is there any way to force Erlang to copy the binary chunk in order to free it from its dependency on the bigger binary, trading a bit of CPU now for a lit of memory soon?

http://erlang.org/doc/man/binary.html#copy-1


More information about the erlang-questions mailing list