<html theme="default-light" iconset="color"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body text="#485663"><span>Ian Chilton wrote on 28/06/2023 07:54:</span><br>
<blockquote type="cite"
cite="mid:4d1589db2e0a79ac2c71aa7fb04af7fc@lonap.net">Anyone have
experience with threads in Perl and able to suggest why?
<br>
</blockquote>
<br>
shorter answer: <a class="moz-txt-link-freetext" href="https://twitter.com/nedbat/status/194452404794691584">https://twitter.com/nedbat/status/194452404794691584</a><br>
<br>
Probably what's happening here is that there is some thread magic going
on behind the scenes which is creating anonymous references to functions
/ variable. If this happens in perl, and the anonymous reference is
lost, then garbage collection won't free up these resources until the
script exits. Although not very sexy, it would probably be safer to
fork a subprocess to handle the flush, rather than using threads. Even
this approach needs to be handled carefully (i.e. close the sflowtool
pipe for the child process, ensure the child process has a well defined
exit point, and put in some magic to ensure that orderly shutdowns
work).<br>
<br>
Nick<br>
<br>
</body></html>