Memory leak in ServerEndpoint channels
AqlaSolutions opened this issue ยท 2 comments
AqlaSolutions commented
AqlaSolutions commented
It looks like the issue might be related to this part of Endpoint
class
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 ValueTask
s before calling AsTask
and waiting.
AqlaSolutions commented
No memory leak after 4 days of testing the merged fix, closing this.