-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
tokio task spawn memory "leak" #4406
Comments
The |
Hi, yeah, sorry for the noise. I researched a bit more, and it seems that the default allocator does not properly free the memory in those situations (I don't completely understand why, though). Thanks |
Allocators hold onto deallocated memory regions to improve allocation throughput. |
This is actually the cause behind most of the leak reports we get for Tokio. It happens for performance reasons — it is faster to hold on to the memory than to release it and then ask for it again later. In your case, I actually guessed that you had commented out the entire for loop (as opposed to just the line with the |
i knew that, but my understanding was/is that there will be memory returned to the host 'under certain conditions' (e.g. see mallopt(3) comment about M_TRIM_THRESHOLD) but in case of glibc it seems not to be that simple.. a program that basically has gigabytes allocated but not used seems rather pointless. in our case, customers ran into oom situations because of the combined used ram of various things, including our main daemon (that "used" >5GiB)
no i deliberately left the 'into_iter()' so that the joinhandles were consumed. i could have phrased it better though, yes. |
Looks like the memory leak was mostly due to thread spawning that would not drop the memory when they are done. Instead we just do a let _ = ... Seems related to this: tokio-rs/tokio#4406 Also fixed a bug that would not detect a legal en-passant move if in check.
Version
tokio v1.15.0
Platform
Linux rust-dev 5.13.19-3-pve #1 SMP PVE 5.13.19-6 (Tue, 11 Jan 2022 16:44:47 +0100) x86_64 GNU/Linux
Description
it seems that some part (i guess it has something to do with spawned tasks) does not return memory as it should
I tried this code:
which allocates up to 1.4GiB! (checking htops RES column) here (16core/32thread epyc) and frees it again when waiting on the input
but if i comment out the line
though, it still consumes the 1.4GiB and never frees it
i expected the resources of a spawned task to be freed in any case, not when i immediately await the spawned tasks
release or debug mode does not seem to make a difference
The text was updated successfully, but these errors were encountered: