From 4ebc5cf1f5dcbc311d126b562b3097697b3f2ba1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 2 Dec 2025 20:13:40 +0000 Subject: [PATCH 1/3] Initial plan From 91ba81969a93e914275f4178b84606d25f739926 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 2 Dec 2025 20:16:56 +0000 Subject: [PATCH 2/3] Add examples to dotnet-gcdump collect and report commands Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com> --- docs/core/diagnostics/dotnet-gcdump.md | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/docs/core/diagnostics/dotnet-gcdump.md b/docs/core/diagnostics/dotnet-gcdump.md index 602a4b444551d..f6ca523bc0c5a 100644 --- a/docs/core/diagnostics/dotnet-gcdump.md +++ b/docs/core/diagnostics/dotnet-gcdump.md @@ -134,6 +134,42 @@ dotnet-gcdump collect [-h|--help] [-p|--process-id ] [-o|--output [!NOTE] > To collect a GC dump using `dotnet-gcdump`, it needs to be run as the same user as the user running target process or as root. Otherwise, the tool will fail to establish a connection with the target process. +### Examples + +- Collect a GC dump from a process with process ID 1902: + + ```dotnetcli + > dotnet-gcdump collect --process-id 1902 + Writing gcdump to './20250601_121500_1902.gcdump'... + Finished writing 5763432 bytes. + ``` + +- Collect a GC dump from a process with process ID 1902 and save it to a custom path: + + ```dotnetcli + > dotnet-gcdump collect --process-id 1902 --output ./myapp-dump.gcdump + Writing gcdump to './myapp-dump.gcdump'... + Finished writing 5763432 bytes. + ``` + +- Collect a GC dump from a process by name with verbose output: + + ```dotnetcli + > dotnet-gcdump collect --name my-aspnet-server --verbose + [20:54:11] Starting gcdump collection... + [20:54:11] Triggering GC... + [20:54:12] Writing gcdump to './20250601_121500_1902.gcdump'... + Finished writing 5763432 bytes. + ``` + +- Collect a GC dump with a custom timeout of 60 seconds: + + ```dotnetcli + > dotnet-gcdump collect --process-id 1902 --timeout 60 + Writing gcdump to './20250601_121500_1902.gcdump'... + Finished writing 5763432 bytes. + ``` + ## `dotnet-gcdump ps` Lists the dotnet processes that GC dumps can be collected for. dotnet-gcdump 6.0.320703 and later, also display the command-line arguments that each process was started with, if available. @@ -179,6 +215,32 @@ dotnet-gcdump report [-h|--help] [-p|--process-id ] [-t|--report-type dotnet-gcdump report ./20250601_121500_1902.gcdump + ``` + + The output displays type statistics: + + ```output + Size (Bytes) Count Type + ============== ===== ==== + 1,603,588,000 22,000,000 System.String + 201,096,000 2,010,000 System.Byte[] + 100,000,000 1,000,000 System.Char[] + 50,000,000 500,000 System.Object[] + 25,000,000 250,000 MyApp.Customer + ``` + +- Generate a heap statistics report from a running process with process ID 1902: + + ```dotnetcli + > dotnet-gcdump report --process-id 1902 + ``` + ## Troubleshoot - There is no type information in the gcdump. From e303c4ca99e5bba68db7b5cb712181c178165076 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 2 Dec 2025 20:18:54 +0000 Subject: [PATCH 3/3] Fix inconsistent process ID in verbose example output Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com> --- docs/core/diagnostics/dotnet-gcdump.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/diagnostics/dotnet-gcdump.md b/docs/core/diagnostics/dotnet-gcdump.md index f6ca523bc0c5a..3f3aa54462800 100644 --- a/docs/core/diagnostics/dotnet-gcdump.md +++ b/docs/core/diagnostics/dotnet-gcdump.md @@ -158,7 +158,7 @@ dotnet-gcdump collect [-h|--help] [-p|--process-id ] [-o|--output dotnet-gcdump collect --name my-aspnet-server --verbose [20:54:11] Starting gcdump collection... [20:54:11] Triggering GC... - [20:54:12] Writing gcdump to './20250601_121500_1902.gcdump'... + [20:54:12] Writing gcdump to './20250601_205412_4521.gcdump'... Finished writing 5763432 bytes. ```