Skip to content

Unmanaged memory growth with DiagnosticsClient #105132

@vaind

Description

@vaind

Description

I'm running a diagnostic session on the program itself (for in-process profiling) and am facing issues noticable in ASP.NET core apps, although I think it's only showing there due to the number of events being produced.

Reproduction Steps

I've created a simple app which just connects a diagnostic session and ignores incoming events:

  1. dotnet new webapi --use-controllers -o webapi
  2. dotnet add package Microsoft.Diagnostics.Tracing.TraceEvent --version 3.1.13
  3. dotnet add package Microsoft.Diagnostics.NETCore.Client --version 0.2.510501
  4. set "System.GC.HeapHardLimit": 5242880 in runtimeconfig to make sure GC runs early
  5. update Program.cs, see repo: https://github.com/vaind/webapi-mem
  6. dotnet build -c Release
  7. run the program and observe unmanaged memory growth

Expected behavior

I'd expect the unmanaged memory to cap at the given circularBufferMB: 16 + some baseline for the runtime of course.

Actual behavior

Memory grows over time:
image

And after a few hours:
image

Regression?

No response

Known Workarounds

No response

Configuration

.NET SDK:
 Version:           8.0.303
 Commit:            29ab8e3268
 Workload version:  8.0.300-manifests.7ccdde63
 MSBuild version:   17.10.4+10fbfbf2e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.303\

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions