MemoryDump Class

Creates memory dumps of the current process.

public static class MemoryDump

Remarks

On Windows, the dump is written from a snapshot of the process (PssCaptureSnapshot) using MiniDumpWriteDump from dbghelp.dll. On Linux and macOS, the dump is written by the createdump tool shipped with the .NET runtime.

A memory dump may contain sensitive data such as credentials, tokens, or connection strings. Store and share it accordingly.

Example

MemoryDump.Write("app.dmp");
await MemoryDump.WriteAsync("app.dmp", MemoryDumpType.WithHeap);

Methods

NameDescription
Write(string, MemoryDumpType)Writes a memory dump of the current process to the specified file.
WriteAsync(string, MemoryDumpType, CancellationToken)Writes a memory dump of the current process to the specified file.

Write(string, MemoryDumpType)

MemoryDump.cs
  • Supported on linux
  • Supported on macos
  • Supported on windows8.1

Writes a memory dump of the current process to the specified file.

[SupportedOSPlatform("linux")]
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows8.1")]
public static void Write(string filePath, MemoryDumpType dumpType = MemoryDumpType.Full)

Parameters

filePath string
The path of the dump file. The file is overwritten if it already exists.
dumpType MemoryDumpType
The content of the dump.

Exceptions

PlatformNotSupportedException
The current operating system is not Windows, Linux, or macOS.

WriteAsync(string, MemoryDumpType, CancellationToken)

MemoryDump.cs
  • Supported on linux
  • Supported on macos
  • Supported on windows8.1

Writes a memory dump of the current process to the specified file.

net10.0

[SupportedOSPlatform("linux")]
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows8.1")]
public static Task WriteAsync(string filePath, MemoryDumpType dumpType = MemoryDumpType.Full, CancellationToken cancellationToken = default)

net11.0

[SupportedOSPlatform("linux")]
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("windows8.1")]
public static Task WriteAsync(string filePath, MemoryDumpType dumpType = MemoryDumpType.Full, CancellationToken cancellationToken = default)

Parameters

filePath string
The path of the dump file. The file is overwritten if it already exists.
dumpType MemoryDumpType
The content of the dump.
cancellationToken CancellationToken
A token to cancel the operation.

Returns

Task

Exceptions

PlatformNotSupportedException
The current operating system is not Windows, Linux, or macOS.