<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-11-02 18:36 GMT-02:00 Joe Groff <span dir="ltr">&lt;<a href="mailto:jgroff@apple.com" target="_blank">jgroff@apple.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><span class="m_-7285089370529100141gmail-"><br><div><blockquote type="cite"><div>On Nov 2, 2016, at 1:16 PM, Bernardo Breder via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt; wrote:</div><br class="m_-7285089370529100141gmail-m_9052333528271717114Apple-interchange-newline"><div><div dir="ltr" style="font-family:helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">In my http server i want to manager the memory all the time that we close a socket, like the example of manager in this link: <a href="http://stackoverflow.com/questions/25860942/is-it-necessary-to-use-autoreleasepool-in-a-swift-program" target="_blank">http://stackoverflow.com<wbr>/questions/25860942/is-it-nece<wbr>ssary-to-use-autoreleasepool-<wbr>in-a-swift-program</a><div><br></div><div>Algorithm that show the ideia:</div><div><br></div><div><i>func request(content) { ... }</i></div><div><i><br></i></div><div><i>let server = myserver()</i></div><div><i>while let client = server.accept() {</i></div><div><b><i>  autoreleasepool {</i></b></div><div><i>    client.send(request(client.rea<wbr>d()))</i></div><div><i>    client.close()</i></div><div><b><i>  }</i></b></div><div><i>}</i></div></div></div></blockquote></div><br></span></div></blockquote><div><br></div><div>The algorithm that i send is a example of server code and this code will execute in a ubuntu environment. When i install in the ubuntu, the swiftc show me that the <span style="font-family:helvetica;font-size:12px"><i style="font-weight:bold">autoreleasepool </i>is &quot;</span><span style="font-size:12.800000190734863px">use of unresolved identifier &#39;autoreleasepool&#39;&quot;. I want to clean the memory all the time when a client close. I will rewrite the example replacing the client for socket:</span><br></div><div><span style="font-size:12.800000190734863px"><br></span></div><div><div>func request(content) { ... }</div><div><br></div><div>let server = myserver()</div><div>while let <b>socket</b> = server.accept() {</div><div>  <b>autoreleasepool</b> {</div><div>    <b>socket</b>.send(request(<b>socket</b>.<wbr>read()))</div><div>    <b>socket</b>.close()</div><div>  }</div><div>}</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><span class="m_-7285089370529100141gmail-"></span><div>Is `client` really getting autoreleased somewhere? autoreleasepool shouldn&#39;t normally be necessary. The client will be released when you go out of scope.</div><span class="m_-7285089370529100141gmail-HOEnZb"><font color="#888888"><div><br></div><div>-Joe</div></font></span></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_-7285089370529100141gmail_signature"><div dir="ltr">Nome : Bernardo Breder<br>Product : Breder Language<br>Site : <a href="http://bernardobreder.com/" target="_blank">bernardobreder.com</a><br>Email : <a href="mailto:bernardobreder@gmail.com" target="_blank">bernardobreder@gmail.com<br></a><div>Email : <a href="mailto:bbreder@tecgraf.puc-rio.br" target="_blank">bbreder@tecgraf.puc-rio.br</a></div><div>Email : <a href="mailto:contato@bernardobreder.com" target="_blank">contato@bernardobreder.com</a><br>Graduação : UFF - Ciência da Computação<div>Mestrado : UFF - Ciência da Computação<br>Trabalho : TecGraf - PUC-RIO</div></div></div></div>
</div></div>