How to generate a dump file of a .NET application
When an application is not running well, it could be useful to generate a dump file to debug it. There are many ways to generate a dump file on Windows, Linux, or Azure.
#Windows
##dotnet-dump (Windows)
The dotnet-dump global tool is a way to collect and analyze dumps for .NET Core applications.
Install
dotnet-dump
(require .NET SDK) or download itShelldotnet tool install --global dotnet-dump
Find the process id using the
ps
commandShelldotnet-dump ps
Generate a dump file for a specific process id
Shelldotnet-dump collect --process-id <ProcessId>
##Windows Task Manager
- Press Ctrl+Shift+Esc to open the Windows Task Manager
- Select the "Details" tab
- Find the application in the list
- Right-click and select "Create dump file"
##SysInternals - Process Explorer
- Download Process Explorer: Process Explorer
- Open Process Explorer
- Right-click on the process and select the "Create Dump" menu item
##SysInternals - ProcDump (Windows)
ProcDump
is a command-line utility that allows generating a dump file when the application freezes or when the process uses too much CPU.
Download ProcDump: ProcDump
Generate a dump file using the process name or process id
procdump notepad
procdump 4572
You can generate a dump file when a specific exception is thrown:
procdump64.exe -e 1 -f IOException myapp.exe
-e 1
means that the dump file is generated when an exception is thrown, including the first-chance exceptions-f IOException
means that the dump file is generated when anIOException
is thrown
##Debug Diagnostic Tool
Debug Diagnostic Tool allows generating a dump file when a condition is met. For instance, it can generate a dump file when the application crashes or when the CPU usage is high.
- Download Debug Diagnostic Tool v2 Update 3
- Start "DebugDiag 2 Collection" (available in the start menu)
- Configure a rule, such as when the application crashes
- When the condition is met, a crash dump is generated in the configured folder
##Visual Studio
If you are debugging an application, you can save a dump file directly from Visual Studio. Open the "Debug" menu and click the "Save dump as…" menu item:
##WinDbg
If you are debugging an application using WinDbg, you can use the .dump
command to generate a dump file. The /ma
option allows generating a minidump for all attached processes.
.dump /ma [path]
##Windows Error Reporting
Windows Error Reporting allows generating a dump file when an application crashes. You can check my previous post about it: Automatically create a crash dump file on error
#Linux
##dotnet-dump (Linux)
The dotnet-dump global tool is a way to collect and analyze dumps for .NET Core applications.
Install
dotnet-dump
(require .NET SDK) or download itShelldotnet tool install -g dotnet-dump
Find the process id using bash or PowerShell
Shelldotnet-dump ps
Generate a dump file for a specific process id
Shelldotnet-dump collect --type heap --process-id <ProcessId>
##SysInternals - ProcDump (Linux)
ProcDump is a command-line utility that allows generating a dump file when the application freezes or when it uses too much CPU.
Download ProcDump for Linux: ProcDump For Linux
Generate a dump file using the process name or process id
procdump 4572
#Azure App Services
Azure allows us to generate and analyze dump files for App Services.
Select your App Service
Go to "Diagnose and solve problems"
Select Diagnose Tools
Select "Collect Memory Dump"
Click on the "Collect Memory Dump" button
After a few minutes, the dump is available in the configured storage account
Do you have a question or a suggestion about this post? Contact me!