Skip to content

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

Open
@AArnott

Description

@AArnott

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions