How to generate a dump file of a .NET application

 
 
  • Gérald Barré

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.

  1. Install dotnet-dump (require .NET SDK) or download it

    Shell
    dotnet tool install --global dotnet-dump
  2. Find the process id using the ps command

    Shell
    dotnet-dump ps
  3. Generate a dump file for a specific process id

    Shell
    dotnet-dump collect --process-id <ProcessId>

##Windows Task Manager

  1. Press Ctrl+Shift+Esc to open the Windows Task Manager
  2. Select the "Details" tab
  3. Find the application in the list
  4. Right-click and select "Create dump file"

##SysInternals - Process Explorer

  1. Download Process Explorer: Process Explorer
  2. Open Process Explorer
  3. 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.

  1. Download ProcDump: ProcDump

  2. Generate a dump file using the process name or process id

    procdump notepad
    procdump 4572

##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.

  1. Download Debug Diagnostic Tool v2 Update 3
  2. Start "DebugDiag 2 Collection" (available in the start menu)
  3. Configure a rule, such as when the application crashes
  4. 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 crash. 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.

  1. Install dotnet-dump (require .NET SDK) or download it

    Shell
    dotnet tool install -g dotnet-dump
  2. Find the process id using bash or PowerShell

    Shell
    dotnet-dump ps
  3. Generate a dump file for a specific process id

    Shell
    dotnet-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.

  1. Download ProcDump for Linux: ProcDump For Linux

  2. 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.

  1. Select your App Service

  2. Go to "Diagnose and solve problems"

  3. Select Diagnose Tools

  4. Select "Collect Memory Dump"

  5. Click on the "Collect Memory Dump" button

  6. 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!

Follow me:
Enjoy this blog?Buy Me A Coffee💖 Sponsor on GitHub