GC.GetAllocatedBytesForCurrentThread 方法

定义

获取自生存期开始以来分配给当前线程的字节总数。

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

返回

自生存期开始以来分配给当前线程的字节总数。

注解

该方法 GetAllocatedBytesForCurrentThread 返回在线程生存期内在托管堆上分配的字节总数,而不是在垃圾回收中幸存的字节总数。 返回的值也不包含任何本机分配。

此方法在监视方案中最有用,用于测量时间间隔或事件之间的内存分配差异。

适用于