Table of Contents

Class OdfMemoryTracker

Namespace
OdfKit.Core
Assembly
OdfKit.dll

Provides the OdfMemoryTracker API. 未受控記憶體安全生命週期追蹤器 (Unmanaged Memory Leak Tracker)。

public static class OdfMemoryTracker
Inheritance
OdfMemoryTracker
Inherited Members

Properties

BoxingWarningThreshold

Gets the BoxingWarningThreshold value. 取得或設定高頻 boxing 估計次數警示門檻。

public static long BoxingWarningThreshold { get; set; }

Property Value

long

DiagnosticsEnabled

Gets a value indicating the DiagnosticsEnabled state. 取得或設定是否啟用記憶體與反模式診斷警示。

public static bool DiagnosticsEnabled { get; set; }

Property Value

bool

LargeAllocationWarningThresholdBytes

Gets the LargeAllocationWarningThresholdBytes value. 取得或設定單次分配大小警示門檻;預設對齊 .NET LOH 常見門檻。

public static long LargeAllocationWarningThresholdBytes { get; set; }

Property Value

long

NodeLoadWarningThreshold

Gets the NodeLoadWarningThreshold value. 取得或設定單次載入節點數警示門檻。

public static long NodeLoadWarningThreshold { get; set; }

Property Value

long

TotalTrackedMemoryWarningThresholdBytes

Gets the TotalTrackedMemoryWarningThresholdBytes value. 取得或設定累計追蹤記憶體警示門檻。

public static long TotalTrackedMemoryWarningThresholdBytes { get; set; }

Property Value

long

TrackedAllocationCountWarningThreshold

Gets the TrackedAllocationCountWarningThreshold value. 取得或設定追蹤分配數量警示門檻。

public static int TrackedAllocationCountWarningThreshold { get; set; }

Property Value

int

Methods

CheckLeaks()

Short overload of CheckLeaks that uses default values for all optional parameters and forwards to the full overload. 便利多載:CheckLeaks 的所有可選參數使用預設值並轉呼叫最長多載。

public static bool CheckLeaks()

Returns

bool

CheckLeaks(bool)

Performs check leaks. 檢查是否有尚未釋放的非受控記憶體。

public static bool CheckLeaks(bool reportLeaks)

Parameters

reportLeaks bool

是否列印洩漏報告

Returns

bool

是否有洩漏

ReportLoadProfile(long)

Short overload of ReportLoadProfile that accepts nodeCount; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 nodeCount;其餘可選參數使用預設值並轉呼叫最長 ReportLoadProfile 多載。

public static void ReportLoadProfile(long nodeCount)

Parameters

nodeCount long

ReportLoadProfile(long, long?)

Short overload of ReportLoadProfile that accepts nodeCount and allocatedBytes; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 nodeCount 與 allocatedBytes;其餘可選參數使用預設值並轉呼叫最長 ReportLoadProfile 多載。

public static void ReportLoadProfile(long nodeCount, long? allocatedBytes)

Parameters

nodeCount long
allocatedBytes long?

ReportLoadProfile(long, long?, long)

Short overload of ReportLoadProfile that accepts nodeCount, allocatedBytes, and boxedValueCount; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 nodeCount、allocatedBytes 與 boxedValueCount;其餘可選參數使用預設值並轉呼叫最長 ReportLoadProfile 多載。

public static void ReportLoadProfile(long nodeCount, long? allocatedBytes, long boxedValueCount)

Parameters

nodeCount long
allocatedBytes long?
boxedValueCount long

ReportLoadProfile(long, long?, long, string?)

Performs report load profile. 回報單次載入或批次操作的記憶體與反模式特徵,超過門檻時輸出診斷警示。

public static void ReportLoadProfile(long nodeCount, long? allocatedBytes, long boxedValueCount, string? label)

Parameters

nodeCount long

本次載入或操作涉及的 DOM 節點數

allocatedBytes long?

本次載入或操作估計配置的位元組數;未知時可為 null

boxedValueCount long

本次操作估計發生的 boxing 次數

label string

選用的情境標籤

Track(nint, long)

Short overload of Track that accepts ptr and size; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 ptr 與 size;其餘可選參數使用預設值並轉呼叫最長 Track 多載。

public static void Track(nint ptr, long size)

Parameters

ptr nint
size long

Track(nint, long, string?)

Performs track. 追蹤非受控記憶體或 POH 鎖定分配。

public static void Track(nint ptr, long size, string? label)

Parameters

ptr nint

記憶體區塊指標

size long

分配的大小 (位元組)

label string

選用的標籤,用於說明分配目的

Untrack(nint)

Performs untrack. 取消追蹤並釋放非受控記憶體。

public static void Untrack(nint ptr)

Parameters

ptr nint

記憶體區塊指標