microsoft / microsoft/vs-streamjsonrpc

Consider using finalizer and weak references to avoid leaks when proxies are abandoned

Open
#1,017 2 comments 0 reactions 0 assignees View on GitHub

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:

  1. Generate proxies with a finalizer
  2. The finalizer should cause the connection to die (or an RPC marshaled object's resources to be recovered).
  3. 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.
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.