Generating and viewing memory dumps
When debugging in Visual Studio, if your program has stopped on a breakpoint or an exception, then the Save Dump As menu option becomes available in the Debug menu.
A minidump with a heap file provides a snapshot of an application's memory, shows the process that was running, and lists the modules that were loaded at a point in time. Dump files enable you to examine the stack, threads, and variables as they were within the application and memory at the point in time when the dump was saved.
You would save a minidump with heap files when testing software and a crash is encountered, and when a customer program crash cannot be replicated on your computer.
Let's go through the process of saving and loading a minidump with a heap file:
- Using our
CH04_WeakReferences
project, put a breakpoint on the following line in theprogram.cs
file:Console.WriteLine("Press any key to continue.");
- Run the project to the breakpoint...