Table of Contents

Class VhTypeTracker

Namespace
VpnHood.Net.Toolkit.Memory
Assembly
VpnHood.Net.Toolkit.dll

Provides a process-wide tracker of objects and events for memory investigations: it counts, by name, the objects it was given that are still alive, and counts named events.

public static class VhTypeTracker
Inheritance
VhTypeTracker
Inherited Members

Remarks

It does nothing until Enabled. Each call takes a lock, so it is no tool for production paths.

Properties

Enabled

Gets or sets a value indicating whether the tracker records. Turning it on clears what was recorded before.

public static bool Enabled { get; set; }

Property Value

bool

Methods

GetSnapshotString()

Returns the tracked objects still alive, counted by name, a task's split into its completed and active ones, and the event counts.

public static string GetSnapshotString()

Returns

string

One line, such as live=[Name:3] events=[Name.created:5].

Record(string)

Counts an event.

public static void Record(string eventName)

Parameters

eventName string

The event's name.

Track(object)

Tracks an object under its type's name, holding it weakly, and counts its creation.

public static bool Track(object obj)

Parameters

obj object

The object.

Returns

bool

true if it is tracked; false when the tracker is off.

Track(object?, string)

Tracks an object under a name, holding it weakly, and counts the event name.created.

public static bool Track(object? obj, string diagnosticName)

Parameters

obj object

The object, or null.

diagnosticName string

The name it is counted under.

Returns

bool

true if it is tracked; false when the tracker is off or the object is null.