Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to capture memory dumps to help debug .NET Core apps, particularly an app that is crashing with a stack overflow exception.

How to Capture Memory Dumps

  1. Download ProcDump
    • ProcDump is a Microsoft Sysinternals command-line utility for creating memory dumps / crash dumps.
  2. Run the following command to start capturing a memory dump anytime an application crashes:
mkdir C:\MemoryDumps
procdump.exe -accepteula -ma -i C:\MemoryDumps
  1. Run the following command to stop capturing a memory dump anytime an application crashes:
procdump.exe -u

Viewing / Debugging a Memory Dump

  1. Copy the dump file to your machine
    • Zip or 7zip the file before transferring to your machine as the files are very large
    • Also, consider uploading the file via OneDrive as a faster way to copy the file to your machine
  2. In Visual Studio, be sure you have reverted your code back to the same version of the app that crashed and re-build the solution in release mode
    • Be sure to place the re-built binaries in the exact same directory on your machine so that Visual Studio can find the .pdb files
  3. In Visual Studio, open the .dmp file and click "Debug with Managed Only"
    • If a "Just My Code Warning" dialog opens, select "Disable Just My Code and Continue"
    • If a Stack Overflow error occurred, it will immediately breakpoint on the exact line that caused the Stack Overflow
    • By debugging the memory dump, you can see all active threads, double click on any thread to see the code and all variables loaded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment