Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions docs/core/diagnostics/dotnet-gcdump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
title: dotnet-gcdump - .NET Core
description: Installing and using the dotnet-gcdump command-line tool.
ms.date: 07/26/2020
---
# Heap analysis tool (`dotnet-gcdump`)

**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions

## Installing `dotnet-gcdump`

To install the latest release version of the `dotnet-gcdump` [NuGet package](https://www.nuget.org/packages/dotnet-gcdump), use the [dotnet tool install](../tools/dotnet-tool-install.md) command:

```dotnetcli
dotnet tool install -g dotnet-gcdump
```

## Synopsis

```console
dotnet-gcdump [-h|--help] [--version] <command>
```

## Description

The `dotnet-gcdump` global tool is a way to collect gcdumps of live .NET processes. It is built using the EventPipe technology which is a cross-platform alternative to ETW on Windows. Gcdumps are created by triggering a GC in the target process, turning on special events, and regenerating the graph of object roots from the event stream. This allows for gcdumps to be collected while the process is running with minimal overhead. These dumps are useful for several scenarios:

- comparing the number of objects on the heap at several points in time.
- analyzing roots of objects (answering questions like, "what still has a reference to this type?").
- collecting general statistics about the counts of objects on the heap.

## Options

- **`--version`**

Displays the version of the `dotnet-gcdump` utility.

- **`-h|--help`**

Shows command-line help.

## `dotnet-gcdump collect`

Collects a gcdump from a currently running process.

### Synopsis

```console
dotnet-gcdump collect [-h|--help] [-p|--process-id <pid>] [-o|--output <gcdump-file-path>] [-v|--verbose] [-t|--timeout <timeout>] [-n|--name <name>]
```

### Options
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the pattern of https://raw.githubusercontent.com/dotnet/docs/master/docs/core/diagnostics/dotnet-counters.md we should have an Examples h3 section following each Options h3 section.


- **`-h|--help`**

Shows command-line help.

- **`-p|--process-id <pid>`**

The process id to collect the gcdump.

- **`-o|--output <gcdump-file-path>`**

The path where collected gcdumps should be written. Defaults to *.\\YYYYMMDD\_HHMMSS\_\<pid>.gcdump*.

- **`-v|--verbose`**

Output the log while collecting the gcdump.

- **`-t|--timeout <timeout>`**

Give up on collecting the gcdump if it takes longer than this many seconds. The default value is 30s.

- **`-n|--name <name>`**

The name of the process to collect the gcdump.

## `dotnet-gcdump ps`

Lists the dotnet processes that gcdumps can be collected.

### Synopsis

```console
dotnet-gcdump ps
```

## `dotnet-gcdump report <gcdump_filename>`

Generate report into stdout from a previously generated gcdump or from a running process.

### Synopsis

```console
dotnet-gcdump report [-h|--help] [-p|--process-id <pid>] [-t|--report-type <HeapStat>]
```

### Options

- **`-h|--help`**

Shows command-line help.

- **`-p|--process-id <pid>`**

The process id to collect the trace.

- **`-t|--report-type <HeapStat>`**

The type of report to generate. Available options: heapstat (default).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the only option, what's the difference between specifying it an omitting it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tdykstra, I had this question myself. It looks like there shouldn't be a difference. Perhaps the tool team might be planning to add other options later?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @josalem

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only report type available right now and therefore the default, but we created this flag for future use if/when we add more report types.