[swift-users] Autoreleasepool for Ubuntu

Bernardo Breder bernardobreder at gmail.com
Wed Nov 2 15:42:23 CDT 2016


2016-11-02 18:36 GMT-02:00 Joe Groff <jgroff at apple.com>:

>
> On Nov 2, 2016, at 1:16 PM, Bernardo Breder via swift-users <
> swift-users at swift.org> wrote:
>
> 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:
> http://stackoverflow.com/questions/25860942/is-it-nece
> ssary-to-use-autoreleasepool-in-a-swift-program
>
> Algorithm that show the ideia:
>
> *func request(content) { ... }*
>
> *let server = myserver()*
> *while let client = server.accept() {*
> *  autoreleasepool {*
> *    client.send(request(client.read()))*
> *    client.close()*
> *  }*
> *}*
>
>
>
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 *autoreleasepool *is "use of unresolved identifier
'autoreleasepool'". I want to clean the memory all the time when a client
close. I will rewrite the example replacing the client for socket:

func request(content) { ... }

let server = myserver()
while let *socket* = server.accept() {
  *autoreleasepool* {
    *socket*.send(request(*socket*.read()))
    *socket*.close()
  }
}


> Is `client` really getting autoreleased somewhere? autoreleasepool
> shouldn't normally be necessary. The client will be released when you go
> out of scope.
>
> -Joe
>



-- 
Nome : Bernardo Breder
Product : Breder Language
Site : bernardobreder.com
Email : bernardobreder at gmail.com
Email : bbreder at tecgraf.puc-rio.br
Email : contato at bernardobreder.com
Graduação : UFF - Ciência da Computação
Mestrado : UFF - Ciência da Computação
Trabalho : TecGraf - PUC-RIO
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161102/0fe67dc8/attachment.html>


More information about the swift-users mailing list