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

Stop leaking JoinableTask via ExecutionContext #348

Merged
merged 6 commits into from
Aug 16, 2018

Conversation

AArnott
Copy link
Member

@AArnott AArnott commented Aug 12, 2018

Fixes #274 and gets the recently added test to pass

As part of this, I consolidate several places we create weak references to JoinableTask so we can share those instances, thus reducing GC pressure.

  • Resolve test failure due to additional allocations (or perhaps simply due to retaining the WeakReference)

@AArnott AArnott added this to the v16.0 milestone Aug 12, 2018
@AArnott AArnott self-assigned this Aug 12, 2018
@AArnott AArnott requested review from sharwell, jviau and lifengl August 12, 2018 18:38
/// <summary>
/// Gets a weak reference to this object.
/// </summary>
internal WeakReference<JoinableTask> WeakSelf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds a cool idea to address this problem. Thanks a lot to take care of it.

Copy link
Member

@lifengl lifengl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I guess the same weakReference is not reused in the JoinableTaskCollection. not sure whether it is worth to do or not...

@AArnott
Copy link
Member Author

AArnott commented Aug 16, 2018

Thanks for the review, @lifengl. Ya, I took a quick look at WeakKeyDictionary to see if we could reuse the weak reference here, and since that would require some significant refactoring I opted to not do it. At least not in this change -- maybe sometime if we see memory pressure to justify it.

@AArnott AArnott merged commit 1d4a8de into microsoft:master Aug 16, 2018
@AArnott AArnott deleted the fix274 branch August 16, 2018 19:46
AArnott pushed a commit that referenced this pull request Feb 10, 2025
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

2 participants