Skip to content
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

JoinHandle wakers are kept alive longer than necessary #6505

Open
Darksonn opened this issue Apr 21, 2024 · 0 comments · May be fixed by #6986
Open

JoinHandle wakers are kept alive longer than necessary #6505

Darksonn opened this issue Apr 21, 2024 · 0 comments · May be fixed by #6986
Labels
A-tokio Area: The main tokio crate M-task Module: tokio/task

Comments

@Darksonn
Copy link
Contributor

Currently, the waker registered with a JoinHandle is not dropped until the task allocation is dropped. This means that if two tasks await each other's JoinHandle, then they will form a reference cycle and the task allocation will never be freed.

The JoinHandle waker should be dropped eagerly once the task has completed and the JoinHandle is dropped.

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-task Module: tokio/task labels Apr 21, 2024
tglane added a commit to tglane/tokio that referenced this issue Nov 23, 2024
dropped or the task completes

Currently, the waker registered with a JoinHandle is not dropped until
the task allocation is dropped. This behaviour may cause the memory
allocated by a task to not be freed when in the case of two tasks
awaiting each others JoinHandle.

This commit changes the behaviour by actively dropping the waker when
the JoinHandle gets dropped (or the task completes in some cases).

Closes tokio-rs#6505.
tglane added a commit to tglane/tokio that referenced this issue Nov 23, 2024
dropped or the task completes

Currently, the waker registered with a JoinHandle is not dropped until
the task allocation is dropped. This behaviour may cause the memory
allocated by a task to not be freed when in the case of two tasks
awaiting each others JoinHandle.

This commit changes the behaviour by actively dropping the waker when
the JoinHandle gets dropped (or the task completes in some cases).

Closes tokio-rs#6505.
tglane added a commit to tglane/tokio that referenced this issue Nov 23, 2024
dropped or the task completes

Currently, the waker registered with a JoinHandle is not dropped until
the task allocation is dropped. This behaviour may cause the memory
allocated by a task to not be freed when in the case of two tasks
awaiting each others JoinHandle.

This commit changes the behaviour by actively dropping the waker when
the JoinHandle gets dropped (or the task completes in some cases).

Closes tokio-rs#6505.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-task Module: tokio/task
Projects
None yet
1 participant