<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 2, 2016, at 13:36, Joe Groff via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">On Nov 2, 2016, at 1:16 PM, Bernardo Breder via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 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:&nbsp;<a href="http://stackoverflow.com/questions/25860942/is-it-necessary-to-use-autoreleasepool-in-a-swift-program" class="">http://stackoverflow.com/questions/25860942/is-it-necessary-to-use-autoreleasepool-in-a-swift-program</a><div class=""><br class=""></div><div class="">Algorithm that show the ideia:</div><div class=""><br class=""></div><div class=""><i class="">func request(content) { ... }</i></div><div class=""><i class=""><br class=""></i></div><div class=""><i class="">let server = myserver()</i></div><div class=""><i class="">while let client = server.accept() {</i></div><div class=""><b class=""><i class="">&nbsp; autoreleasepool {</i></b></div><div class=""><i class="">&nbsp; &nbsp; client.send(request(client.read()))</i></div><div class=""><i class="">&nbsp; &nbsp; client.close()</i></div><div class=""><b class=""><i class="">&nbsp; }</i></b></div><div class=""><i class="">}</i></div></div></div></blockquote></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Is `client` really getting autoreleased somewhere? autoreleasepool shouldn't normally be necessary. The client will be released when you go out of scope.</div></div></blockquote><br class=""></div><div>The problem is that on Apple platforms, the Foundation APIs used to implement the client autorelease things all over the place, so you need an autorelease pool <i class="">somewhere</i>&nbsp;to clean up the <strike class="">mess</strike>&nbsp;intermediate objects returned at +0.</div><div><br class=""></div><div>Jordan</div><br class=""></body></html>