-
-
Notifications
You must be signed in to change notification settings - Fork 357
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
The AsyncLazy<T> does not release resources closed over by the factory delegate #256
Comments
Does this reproduce the problem?
|
@DaveVdE no, it doesn't. The |
Sure, it's missing the Oh I see, your point is that the function passed to the |
@DaveVdE yep, as it does the native |
I sent a fix #269. |
Description
Hi! I am reporting an issue that I discovered after reading a comment by Servy here. In case the
factory
delegate of anAsyncLazy<T>
instance closes over some expensive resource, this resource will not be eligible for garbage collection after the completion of the delegate.Reproduction Steps
Output:
Online demo.
Expected behavior
The
GC.GetTotalMemory()
after awaiting theAsyncLazy<T>
should be roughly the same as before.Actual behavior
The
GC.GetTotalMemory()
after awaiting theAsyncLazy<T>
is around 20 MB more than before.Configuration
Other information
After switching to a simpler
AsyncLazy<T>
implementation like the one below, the problem is not reproduced:Output:
The text was updated successfully, but these errors were encountered: