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

Memory leak in ServerEndpoint channels #2110

Closed
AqlaSolutions opened this issue Mar 27, 2024 · 2 comments
Closed

Memory leak in ServerEndpoint channels #2110

AqlaSolutions opened this issue Mar 27, 2024 · 2 comments

Comments

@AqlaSolutions
Copy link
Contributor

AqlaSolutions commented Mar 27, 2024

Hi, we've encountered an issue that after some time of load testing the memory usage increases and never goes down even after stopping sending new requests.
From dotMemory snapshot:
image

What can cause this?

@AqlaSolutions
Copy link
Contributor Author

AqlaSolutions commented Mar 27, 2024

It looks like the issue might be related to this part of Endpoint class
image

With each loop iteration you perform a new call to WaitToReadAsync and create 2 new tasks for both readers even when only one of the previous two task was completed. This enqueues a new AsyncOperation instance each time which is not removed until anything is written to the channel. So, to avoid this issue, re-use the existing reader task when it's not completed.

Also, as an optimization, consider checking the IsCompleted property of these ValueTasks before calling AsTask and waiting.

@AqlaSolutions
Copy link
Contributor Author

No memory leak after 4 days of testing the merged fix, closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants