[erlang-questions] Port handlers and binary leaks?
Mon Oct 17 18:12:03 CEST 2016
I find the easiest way to think about (large) binaries is through
remembering that they are shared "objects". Any process that has a
"pointer" into a binary like that, means the binary as a whole needs to
stick around. Pattern matching on binaries creates such pointers.
A common problem arises when you have one process creating such a binary,
then taking it apart using pattern matching, and passing those "parts" on
for further processing. All those parts now refer back to the original
large binary, which therefore cannot get collected.
In order to work around this "optimisation", the common approach is for
the process taking apart the binary to make copies of the parts to pass
along for further processing. Thus references into the original binary are
avoided and it can get collected.
On 17 Oct 2016 13:26, "Oliver Korpilla" <> wrote:
> Recent reading got me concerned about leaking memory by having big refc
> In our system we have permanent TCP and SCTP handlers that receive outside
> messages, then forward it into the system for processing.
> For example, these events have ASN.1 payloads. Decoding is done in
> throw-away processes... however, I'm concerned that the TCP and SCTP
> handling processes might cause memory leaks because every payload buffer is
> handled there first.
> I saw in "Erlang in Anger" that routers should only return where to route
> to, not handle the message. But when handling sockets I don't see that
> What is good practice here? Am "I" at risk?
> Thanks and best regards,
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions