語言

GC.GetAllocatedBytesForCurrentThread 方法

定義

取得自執行緒生命週期開始以來分配給該執行緒的總位元組數。

public:
 static long GetAllocatedBytesForCurrentThread();
public static long GetAllocatedBytesForCurrentThread();
static member GetAllocatedBytesForCurrentThread : unit -> int64
Public Shared Function GetAllocatedBytesForCurrentThread () As Long

傳回

自執行緒生命週期開始以來分配給該執行緒的總位元組數。

備註

此 GetAllocatedBytesForCurrentThread 方法回傳的是執行緒生命週期內分配到管理堆積的總位元組數,而非經過垃圾回收後存活的總位元組數。 回傳的值也未包含任何原生配置。

此方法在監控情境中最為有用,以衡量時間區間或事件間記憶體分配的差異。

適用於