Skip to content

Add memory leak tests for request handling and hot reload #2160

Open

Description

@waldekmastykarz

What we need

Deterministic tests proving Dev Proxy doesn't retain memory across (a) many proxied requests and (b) repeated hot reloads.

Problem and who it's for

How to implement

In DevProxy.Integration.Tests, using the existing in-process harness (KestrelProxyHarness / PluginTestHost, FakeOrigin):

  1. Hot reload retention: start the proxy with a config, trigger N (e.g. 20) hot reloads by rewriting the config file. Hold WeakReferences to each previous generation's root objects (plugin instances / per-generation service provider). After GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect();, assert all previous generations are collected. This is exact rather than threshold-based.
  2. Per-request retention: warm up with ~1k requests (mocked via MockResponsePlugin and passthrough to FakeOrigin, including large bodies and a cancelled/failed request), take GC.GetTotalMemory(forceFullCollection: true), send ~10k more, measure again, assert growth below a small bound (e.g. a few MB). Also assert per-request objects (e.g. session/log buffers) are collected via WeakReference where we can reach them.
  3. Keep runtime under ~1 minute; run in the integration test job. Mark as non-parallel if needed (TestParallelization).

Done when

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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