GC.GetAllocatedBytesForCurrentThread 方法

定義

取得自目前執行緒的存留期開始,已配置給該執行緒的位元組總數。

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

傳回

Int64

自目前執行緒的存留期開始,已配置給該執行緒的位元組總數。

備註

方法 GetAllocatedBytesForCurrentThread 會傳回線上程存留期間,在 Managed 堆積上配置的位元組總數,而不是在垃圾收集中存留的位元組總數。 傳回的值也不包含任何原生配置。

此方法最適合用於監視案例,以測量時間間隔或事件之間的記憶體配置差異。

適用於