Dennis
Dennis

Reputation: 37780

How to collect a dump using dotnet-dump after garbage collection is finished?

I want to collect a dump for .NET 6 app (Windows service) which runs in production environment.
The main goal is to analyze managed memory, but all attempts to collect it were finished with dumps collected in the middle of garbage collection.

I thought, that dotnet-dump could help me, but another dump I've got has the same issue. Is there a wat to tell dotnet-dump something like "wait for GC to complete, then collect the dump"?

There is similar question for ProcDump here, but answer is based on performance counter, which is absent on the target machine (and, probably, irrelevant for .NET 6).

Any solutions?

Upvotes: 0

Views: 881

Answers (1)

kareem shibli
kareem shibli

Reputation: 1

you can try to the following:

  • run dotnet-gcdump collect command. this command will trigger gc and then collects events from gc. in your case you don't care about the generated dump but we are using this to call gc indirectly.
  • run dotnet-dump right after running dotnet-gcdump

you can validate this by running dotnet-counters monitor and looking at heap size counter you will see after gcdump heap size is decreasing because of gc.

Upvotes: 0

Related Questions