Document DeleteObjectReference to prevent memory leaks in Orleans observers#51986
Open
Document DeleteObjectReference to prevent memory leaks in Orleans observers#51986
Conversation
Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Mention DeleteObjectReference for Orleans observers
Document DeleteObjectReference to prevent memory leaks in Orleans observers
Mar 3, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Orleans observers documentation to explicitly call out that CreateObjectReference must be paired with DeleteObjectReference to avoid leaking registrations in the client and potentially crashing long-running client processes.
Changes:
- Adds
DeleteObjectReferenceguidance to the introductory explanation of client observers. - Adds a cleanup snippet showing unsubscribe + object reference deletion.
- Adds an
[!IMPORTANT]warning emphasizing the memory-leak/crash risk whenDeleteObjectReferenceis omitted.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Calling
CreateObjectReferencewithout a matchingDeleteObjectReferenceleaves a reference inInvokableObjectManager.localObjects, causing a memory leak that can eventually crash the client process. The observers article never mentioned this requirement.Changes
DeleteObjectReferencemust be called when the observer is no longer needed, cross-referenced via<xref:Orleans.IGrainFactory.DeleteObjectReference*>.[!IMPORTANT]callout: Warns that omittingDeleteObjectReferenceleaks a reference in the client's internal object manager and can eventually crash the process.Original prompt
DeleteObjectReferencewhen talking about Orleans Observers #43439✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Internal previews