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 ValueTask.AsAsync() #15

Open
mvkara opened this issue Dec 11, 2022 · 1 comment
Open

Memory leak in ValueTask.AsAsync() #15

mvkara opened this issue Dec 11, 2022 · 1 comment
Assignees

Comments

@mvkara
Copy link

mvkara commented Dec 11, 2022

Memory leak is in the ContinueWith() section with the captured lambda parameter (despite the use of the wildcard) or the task being captured longer than it is needed.

When in use with a recursive async where it does a ValueTask/Task conversion, looks at the result and potentially recurses the action in the ContinueWith block appears effectively for the lifetime of the loop at times. This could be the life of the whole program as the Action may never return meaning the task's result is held in memory by this ContinueWith function. If the async is recursive and runs this over and over this could result in all task results remaining in memory. Switching to old fashioned Async.AwaitTask when awaiting the task in the async loop fixes the issue.

I think that the Infrastructures.asAsyncV function retains the object when memory profiling. Could be the wildcard arg, or the task object itself. I found this when profiling, tough leak to spot.

@kekyo
Copy link
Owner

kekyo commented Dec 16, 2022

@mvkara Thanks for the report, I have released FusionTasks as a final version. But now that I see it, I think I might be able to do something more, so I will try to think of more ways to implement this.

@kekyo kekyo self-assigned this Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants