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

>
> On Nov 2, 2016, at 1:16 PM, Bernardo Breder via swift-users <
> swift-users@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 : bernardobre...@gmail.com
Email : bbre...@tecgraf.puc-rio.br
Email : cont...@bernardobreder.com
Graduação : UFF - Ciência da Computação
Mestrado : UFF - Ciência da Computação
Trabalho : TecGraf - PUC-RIO
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to