-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
例子循环10000次出错 #5
Comments
the Operating System runs out of memory for TCP buffers. |
callServer函数里面,不是有client.Close()吗?这个循环是顺序来的,建立一个client,执行,close这个client;这样也会耗光内存?除非这个close不是马上执行的? |
我明天测一下,看你提供的错误似乎资源不足。 |
你说的逻辑没错,callServer是在一个goroutine中顺序执行的。但是socket关闭后端口并不会释放,相应的端口会处于TIME_WAIT的状态,只有等待两个MSL才会释放。 这不仅仅是在Windows上的问题,Linux也有这个问题。 所以你可以把HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/TcpTimedWaitDelay改小,促使port尽快释放。 更有效的是使用client pool.只保留几个长连接。我会加上连接池的例子。
|
明白,是TIME_WAIT的状态,谢谢解释! |
multi_server,将client_consistenthash.go中10改成10000后测试出现错误:
error for Arith: 7*8, dial tcp 127.0.0.1:8973: bind: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.
win7 64位系统, go version go1.6 windows/amd64
The text was updated successfully, but these errors were encountered: