memoryviewer
v1.2.0
Published
Interactive viewer for .NET heap snapshots (.gcdump.json produced by dotnet-gcdump --format json).
Maintainers
Readme
Memory Viewer
Interactive viewer for .NET managed heap snapshots. It reads the .gcdump.json files written by
dotnet-gcdump collect --format json (or dotnet-gcdump convert <file>.gcdump --format json) and runs
entirely in the browser, so it can be embedded in tools such as VS Code webviews or opened standalone.
Please note that this tool was created using Claude Code and Fable 5.1.
DotRush also creates original
.gcdumpfiles, which can always be opened in another editor.
Views
- Summary – heap types with instance count, shallow size and retained size, optionally grouped by assembly or namespace; expand a type to see its instances.
- Dominators – the dominator tree: each object under the single object that keeps it alive, biggest retained size first. Objects that several places reference sit directly under the root category with a "N referrers" note.
- GC Roots – static fields, thread stacks and handles, followed along their references.
- Graph – retention graph of the focused object: retainers layered toward the GC roots above, references below.
- Leak Suspects – heuristics, most severe first: objects kept alive only by delegates (subscribers of a static event, timer targets, closures in a static list; graded by whether one long-lived owner accumulates them), event handler lists with many subscribers of one type, deep same-type chains, pinned objects, static fields holding the most memory, largest retained objects and collections, crowded types, objects waiting for finalization, the runtime's static storage, unreachable objects. Size alone never ranks above a leak pattern.
- Compare – type-level diff against a second snapshot of the same process.
The bottom pane shows the selected object's retainers, references, every GC root that reaches it (each with one shortest path) and its dominator chain. The context menu of any row opens the object in the Graph, reveals it in the Dominators view or shows its type in the Summary.
A gcdump does not record which live objects still have a pending finalizer, so objects that were never disposed cannot be told apart from disposed ones; only objects already waiting for the finalizer thread are reported.
What the synthetic nodes mean
dotnet-gcdump adds a few nodes that are not heap objects. The viewer shows them in italics, with readable names,
and keeps them out of the type list:
| In the file | Shown as | Meaning |
| --- | --- | --- |
| [.NET Roots] | GC roots | The starting point of the garbage collector. |
| [static vars], [static var T.field] | Static fields, static T.field | One root per static field. The name is the runtime type of the referenced object plus the field name; the declaring class is not recorded. |
| [local vars] | Local variables | References on thread stacks and in registers. |
| [strong Handles], [pinning Handles], [finalizer Handles], [Dependent Handles] | Strong handles, Pinned handles, Finalizer queue, Dependent handles | GC handles and the finalization queue. |
| UNDEFINED | Unknown object | A reference to an address that is not an object in the dump. |
| T (Bytes > 10K) | T | The dumper splits big objects into size buckets; the viewer merges them back into the type. |
| []c__DisplayClass1_0 | <>c__DisplayClass1_0 | The dumper writes compiler-generated <> as []; the viewer restores it. |
Since .NET 8 the runtime keeps the values of static fields in pinned System.Object[] blocks that are rooted by
strong handles, so every static value has two retainers in the dump and the static roots retain nothing. The viewer
recognizes those blocks (tagged static storage), drops their duplicate references and recomputes the dominator
tree, so that static fields own what they keep alive and the biggest ones show up in the Dominators view and in the
Leak Suspects.
Embedding
The page exposes window.memoryViewer:
interface MemoryViewerApi {
version: string;
loadFromUrl(url: string, fileName?: string): Promise<void>;
loadFromText(text: string, fileName: string): Promise<void>;
loadFromJson(json: unknown, fileName: string): Promise<void>;
configure(options: {
/** Hide the file-open buttons when the host provides the data. */
embedded?: boolean;
/** Let the host pick a baseline snapshot for the Compare view. */
pickSnapshot?: () => Promise<{ fileName: string; url?: string; text?: string } | undefined>;
}): void;
}Snapshot format (.gcdump.json, version 1)
{
"version": 1, "creationTool": "dotnet-gcdump", "timeCollected": "...", "processName": "...", "processId": 0,
"totalProcessWorkingSet": <bytes>, "totalProcessCommit": <bytes>, // process memory when the dump was taken
"totalSize": <bytes>, "rootIndex": <node index of "[.NET Roots]">,
"gcHeapSize": <bytes>, // GC heap after the forced collection (optional)
"gcGenerationSizes": [gen0, gen1, gen2, loh, poh], // per generation, same moment (optional)
"gcSegments": [{ "start", "end", "gen0End", "gen1End", "gen2End", "gen3End", "gen4End" }, ...], // optional
"types": [{ "name": "System.String", "module": "System.Private.CoreLib.dll" }, ...],
"nodes": [typeIndex, size, childCount, ...], // one triplet per node
"edges": [...], // child node indexes, grouped per node
"addresses": [...], // object address per node, 0 for synthetic root nodes
"dominators": [...], // immediate dominator per node, -1 for the root / unreachable
"retainedSizes": [...] // size of the node plus everything it dominates
}License
MIT. The icons are codicons by Microsoft, licensed under
CC-BY-4.0; their license ships as codicons.LICENSE.txt next to the build.
