microsoft / microsoft/vs-streamjsonrpc
Consider using finalizer and weak references to avoid leaks when proxies are abandoned
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 937
- Forks
- 178
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 28
Description
We might be able to allow finalization to recover leaked memory by:
- Generate proxies with a finalizer
- The finalizer should cause the connection to die (or an RPC marshaled object's resources to be recovered).
- If a proxy's backdoor interfaces are accessed such that another proxy or direct JsonRpc object access was obtained, shut off the self-destruct feature since we can no longer be confident that dropping the proxy indicates permanent loss of access to the JSON-RPC connection.
- To support proxies that raise events, JsonRpc should only retain a reference to it when there are actually handlers added to these events.
Note this is just a best-effort mitigation. The documentation should still emphasize the importance of disposing proxies.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how proxies are generated, how JsonRpc retains proxy and event references, and how proxy disposal currently releases resources. Review the finalizer, weak-reference, backdoor-interface, and event-handler requirements in the issue. Done means abandoned proxies can recover resources without breaking proxies whose access has escaped, while disposal remains documented as important.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend-api-design, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100