Skip to content

UnreferenceDisposable made slimmer #627

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

Merged
merged 2 commits into from
Jul 18, 2025

Conversation

Scooletz
Copy link
Contributor

@Scooletz Scooletz commented Jul 16, 2025

A minor adjustement in UnreferenceDisposable so that it's smaller. UnreferenceDisposable had two references previously. One for the session, one for the time provider. Now it has one so whenever UnreferenceDisposable is created for scoping, the allocated object has one less reference to capture.

Motivation and Context

Going through the project and finding optimization opportunities.

How Has This Been Tested?

Locally, unit tests.

Breaking Changes

Nope

Types of changes

  • Optimization
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@eiriktsarpalis
Copy link
Member

Not sure I understand how this is made smaller? It's adding a property when previously only a field was being used.

@Scooletz
Copy link
Contributor Author

Scooletz commented Jul 16, 2025

UnreferenceDisposable had two references previously. One for the session, one for the time provider. Now it has one so whenever UnreferenceDisposable is created for scoping, the allocated object is smaller by one reference.

@eiriktsarpalis
Copy link
Member

When you say references, I presume you mean constructor parameters? While your changes are removing one parameter, they are also introducing a property getter in the containing class, so from an IL size perspective this is probably increasing it rather than decreasing it.

@Scooletz
Copy link
Contributor Author

I mean the underlying fields created behind the scenes. Before this PR there are two fields in UnreferenceDisposable that hold references. After this PR there's one field.

@eiriktsarpalis
Copy link
Member

I see, thanks.

@halter73 halter73 merged commit bd5aef6 into modelcontextprotocol:main Jul 18, 2025
6 of 7 checks passed
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.

3 participants