Memory.Introspect 25.12.63120

dotnet add package Memory.Introspect --version 25.12.63120
                    
NuGet\Install-Package Memory.Introspect -Version 25.12.63120
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Memory.Introspect" Version="25.12.63120" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Memory.Introspect" Version="25.12.63120" />
                    
Directory.Packages.props
<PackageReference Include="Memory.Introspect" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Memory.Introspect --version 25.12.63120
                    
#r "nuget: Memory.Introspect, 25.12.63120"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Memory.Introspect@25.12.63120
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Memory.Introspect&version=25.12.63120
                    
Install as a Cake Addin
#tool nuget:?package=Memory.Introspect&version=25.12.63120
                    
Install as a Cake Tool

Memory Introspect

Programmatic .gcdump capture for .NET applications.

Memory.Introspect

Memory.Introspect is a lightweight C# library that wraps the functionality of the official dotnet-gcdump tool. It allows developers to capture garbage collection (GC) dumps and memory graphs directly from within their code, without needing to shell out to the CLI or manage external processes.

🚀 Why use this?

Normally, capturing a .gcdump requires running the dotnet-gcdump command-line tool against a Process ID (PID). While effective for ad-hoc debugging, it is difficult to automate within an application.

Memory.Introspect allows you to:

  • Self-Monitor: Have an application trigger its own memory dump to analyze memory leaks.
  • Automate: Integrate memory capturing into integration tests or CI/CD pipelines.
  • Streamline: Avoid parsing CLI text output; work with strong types and direct boolean results.

📦 Installation

Memory.Introspect

Memory.Introspect is available as a NuGet package

dotnet add package Memory.Introspect

💻 Usage

The library exposes a simple CollectMemoryGraphAsync method that connects to the target process via the .NET Diagnostics Client (EventPipe).

Basic Example

Here is how to capture the current process's memory graph and save it to a temporary file:

using System.Diagnostics;
using Memory.Introspect;
using Microsoft.Extensions.Logging;

int currentPid    = Process.GetCurrentProcess().Id;

var loggerFactory = LoggerFactory.Create(f => f.AddConsole());
var logger = loggerFactory.CreateLogger("Memory.Introspect");

logger.LogInformation("Starting creating gcdump file from process {0}", currentPid);

var result = await Memory.Introspect.Create(new() { Logger = logger, Verbose = true }).CollectMemoryGraphAsync(currentPid);

if (result.Success)
{
    var gcDumpFile =  $"{DateTimeOffset.UtcNow:yyyy-MM-dd-HH-mm-ss}-process-{currentPid}.gcdump";
    logger.LogInformation("Writing .gcdump file to {0}", gcDumpFile);
    result.SaveToDisk(gcDumpFile);
}

logger.LogInformation("Finished creating gcdump file");

Analyzing the Output

The resulting .gcdump file can be opened in:


⚙️ Configuration Options

When initializing the Memory.Introspect, you can pass a configuration object:

Option Type Description
Logger ILogger Used to log the internal diagnostics protocol progress (Handshake, EventPipe setup, etc.).
Verbose bool If true, outputs detailed logs regarding the connection status and graph construction.
Timeout TimeSpan (Optional) Set a maximum duration for the collection process before cancelling. Minimum of 30s.

⚠️ Requirements & Limitations

  • Platform: Works on Windows, Linux, and macOS.
  • Privileges: The process running the code must have sufficient privileges to access the target process via the Diagnostics Client. If capturing the current process, standard user privileges are usually sufficient.
  • Runtime: Requires .NET 6 or later.

⚖️ License & Attribution

This project is licensed under the MIT License.

Note: This library is heavily based on the source code of the official dotnet-gcdump tool provided by the .NET team.

The core logic for EventPipe communication and Graph construction is adapted from: https://github.com/dotnet/diagnostics/tree/main/src/Tools/dotnet-gcdump

We are grateful to the .NET Diagnostics team for their open-source contributions.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
25.12.63120 840 12/9/2025
25.12.63119 422 12/9/2025