[erlang-questions] Garbage collecting binaries

Masklinn masklinn@REDACTED
Sat Oct 9 09:28:57 CEST 2010


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?


More information about the erlang-questions mailing list