Skip to content

Possible memory leaks in stitching #2962

@benmccallum

Description

@benmccallum

Describe the bug
We're seeing consistently climbing memory usage (very slow, abuot 50MB per hour), but only on the gateway service. I've swept through the HotChocolate.Stitching code and, with the help of this extension found some cases of IDisposable instances not being disposed of potentially and that need reviewing.

To Reproduce
Steps to reproduce the behavior:

  1. Install the extension
  2. Investigate the following locations in code that are giving warnings (green squigglies):
    1. HotChocolate.Stitching.Requests.StitchingContext - the ctor build a dictionary of RemoteRequestExecutor instances but never disposes of them. This is setup in DI as scoped, so the caching is only useful in the scope and they should be disposed of. Perhaps StitchingContext needs to implement IDisposable and dispose it's dictionary entries?
    2. HotChocolate.Stitching.Requests.MergeRequestHelper::DispatchResults - IQueryResult instances are being flagged
    3. HotChocolate.Stitching.Pipeline.HttpRequestClient::FetchAsync - IQueryResult instance being flagged
    4. Microsoft.Extensions.DependencyInjection.HotChocolateStitchingRequestExecutorExtensions::AddRemoteSchema and AddLocalSchema - line 241 RequestExecutorProxy is being flagged though maybe these are OK as they're singleton/static in nature, only created at schema build time?

Expected behavior
Hopefully less climbing memory, though it's a very slow burn up.

Desktop (please complete the following information):

  • OS: Linux alpine containers
  • Version HCv11.0.8

Additional context
We've profiled with dotMemory running 10 thousand queries against the gateway, with a variation of node queries (to test my custom node resolver) and other general queries to test stitching, and not noticed anything particularly dramatic or that stands out.

Metadata

Metadata

Assignees

Labels

Area: StitchingIssue is related to schema stitching / federation⌛ staleNothing happened with this issue in quite a while🌶️ hot chocolate

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions