GC.GetAllocatedBytesForCurrentThread 方法

定义

获取自当前线程的生存期开始以来分配给它的总字节数。Gets the total number of bytes allocated to the current thread since the beginning of its lifetime.

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

返回

自当前线程的生存期开始以来分配给它的总字节数。The total number of bytes allocated to the current thread since the beginning of its lifetime.

注解

GetAllocatedBytesForCurrentThread 方法返回在线程的生存期内在托管堆上分配的字节总数,而不是在垃圾回收后的总字节数。The GetAllocatedBytesForCurrentThread method returns the total number of bytes allocated on the managed heap during the lifetime of a thread, not the total number of bytes that have survived garbage collection. 返回的值还不包括任何本机分配。The returned value also does not include any native allocations.

此方法对于测量时间间隔或事件之间的内存分配差异的监视方案最为有用。This method is most useful in monitoring scenarios for measuring the difference in memory allocation between time intervals or events.

适用于