<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>So...</div>
<div> </div>
<div>Doing a pattern match in a function signature or a case or in a = operator creates a reference.</div>
<div> </div>
<div>Making something part of a list or map makes a reference. (Previous poster said so)</div>
<div> </div>
<div>How about passing something as function argument?</div>
<div> </div>
<div>How about when I match an integer value out of a bitstring by match - does this create a reference? I would think not, since I retain not the binary, but extract a value...</div>
<div> </div>
<div>Thanks and regards,</div>
<div>Oliver</div>
<div>
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b> Montag, 17. Oktober 2016 um 18:12 Uhr<br/>
<b>Von:</b> "Robert Raschke" <rtrlists@googlemail.com><br/>
<b>An:</b> "Oliver Korpilla" <Oliver.Korpilla@gmx.de><br/>
<b>Cc:</b> "Erlang Questions" <erlang-questions@erlang.org><br/>
<b>Betreff:</b> Re: [erlang-questions] Port handlers and binary leaks?</div>
<div name="quoted-content">
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>Cheers,<br/>
Robby</p>
<div class="gmail_quote">On 17 Oct 2016 13:26, "Oliver Korpilla" <<a href="mailto:Oliver.Korpilla@gmx.de" onclick="parent.window.location.href='Oliver.Korpilla@gmx.de'; return false;" target="_blank">Oliver.Korpilla@gmx.de</a>> wrote:
<blockquote class="gmail_quote" style="margin: 0 0 0 0.8ex;border-left: 1.0px rgb(204,204,204) solid;padding-left: 1.0ex;">Hello.<br/>
<br/>
Recent reading got me concerned about leaking memory by having big refc binaries.<br/>
<br/>
In our system we have permanent TCP and SCTP handlers that receive outside messages, then forward it into the system for processing.<br/>
<br/>
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.<br/>
<br/>
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 option?<br/>
<br/>
What is good practice here? Am "I" at risk?<br/>
<br/>
Thanks and best regards,<br/>
Oliver<br/>
_______________________________________________<br/>
erlang-questions mailing list<br/>
<a href="mailto:erlang-questions@erlang.org" onclick="parent.window.location.href='erlang-questions@erlang.org'; return false;" target="_blank">erlang-questions@erlang.org</a><br/>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a></blockquote>
</div>
</div>
</div>
</div></div></body></html>