-
Notifications
You must be signed in to change notification settings - Fork 737
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
Windows mio leaks memory when poll does not retrieve any event #1146
Comments
…any event. In case there are no events retrieved by poll, SockState is leaked because of one of its Arc wrapped in self_wrapped. To prevent this, make sure to decrease reference count of the SockState Arc wrapped by the self_wrapped in case the overlapped is not used. Signed-off-by: Daniel Tacalau <dst4096@gmail.com>
…any event. Pending sockets should be cancelled on inner selector drop, otherwise SockState is leaked. SockState Arc, wrapped in self_wrapped, is used as overlapped data for polling through Afd NtDeviceIoControlFile, so the SockState memory cannot be dropped unless this operation complete successfuly or is cancelled. Signed-off-by: Daniel Tacalau <dst4096@gmail.com>
… improvements. All registered sock_states are saved in a slab data structure. Sock_states are removed from slab during deregister. A reregister expects to find the sock_state saved in slab already. During Selector drop all sock_states from the slab are cancelled and dropped. The slab saves sock_states as pairs of (key, sock_state). The key is also saved in the sock_state and used as overlapped data. Later, when receiving the completion event, the key is used to retrieve the sock_state. The slab will never get full of unusable sock_states which have been marked for deletion because, once a sock_state has been marked for deletion it will also be removed from the slab. Specific cases which should trigger the removal are: 1. a sock_state for which completion returned error, i.e ERROR_INVALID_HANDLE; 2. a sock_state for which a an LOCAL_CLOSE event was retrieved; Signed-off-by: Daniel Tacalau <dst4096@gmail.com>
…k state Arc is blocked by a pending afd poll request, this reference will leak if there's no explicit poll done before the program terminates. That's why doing an explicit "select" during iner selector drop ensures all sock state references are freed. Signed-off-by: Daniel Tacalau <dst4096@gmail.com>
@Thomasdezeeuw please assign this issue to me, thanks. |
…keep things simple in the Drop impl. Signed-off-by: Daniel Tacalau <dst4096@gmail.com>
Fixed leaked sock states, issue tokio-rs#1146. A reference of the sock state Arc is blocked by a pending AFD poll request, this reference will leak if there's no explicit poll done before the program terminates. That's why doing an explicit "select" during iner selector drop ensures all sock state references are freed. Signed-off-by: Daniel Tacalau <dst4096@gmail.com>
A reference of the sock state Arc is blocked by a pending AFD poll request, this reference will leak if there's no explicit poll done before the program terminates. That's why doing an explicit "select" during inner selector drop ensures all sock state references are freed. Fixes: tokio-rs#1146 Signed-off-by: Daniel Tacalau <dst4096@gmail.com>
…k state Arc is blocked by a pending afd poll request, this reference will leak if there's no explicit poll done before the program terminates. That's why doing an explicit "select" during iner selector drop ensures all sock state references are freed. Signed-off-by: Daniel Tacalau <dst4096@gmail.com>
…keep things simple in the Drop impl. Signed-off-by: Daniel Tacalau <dst4096@gmail.com>
Commit 2b68a4b fixed this, but I'm not too happy with the solution. |
A reference of the sock state Arc is blocked by a pending AFD poll request, this reference will leak if there's no explicit poll done before the program terminates. That's why doing an explicit "select" during inner selector drop ensures all sock state references are freed. Fixes: tokio-rs#1146 Signed-off-by: Daniel Tacalau <dst4096@gmail.com>
Hi... I have an odd one and wondering if it is related... I have a case where there is a runaway process in a futures::block_on. It seems to be happening when there is a NIC reset, which happens on logins (for some silly reason)... Just asking for a sanity check tokio:0.2.22 / mio v0.6.22 |
Can you try Mio 0.7? It should be fixed it that. |
@Thomasdezeeuw , |
Any chance you can update to Tokio v0.3? The Windows implementation was rewritten completely, so honestly I don't want to spend too much time on fixing this. |
@Thomasdezeeuw 👍 Thanks for lookin into it. |
This has been fixed. |
Steps to reproduce:
The text was updated successfully, but these errors were encountered: