7

.NET で、スレッド ローカル ストレージが使用しているメモリの量を判断する方法はありますか?

具体的には、ThreadStatic オブジェクトによって使用されるメモリの量と、Thread データ スロット内のオブジェクトに割り当てられたメモリ (たとえば、Thread.SetData を呼び出すことによって) によって使用されるメモリの量を見つけようとしています。

明確にするために:

スレッド ローカル ストレージ: http://msdn.microsoft.com/en-us/library/6sby1byh.aspx

スレッド ローカル ストレージ: スレッド相対静的フィールドとデータ スロット http://msdn.microsoft.com/en-us/library/6sby1byh.aspx

4

1 に答える 1

2

You can get the memory usage by process as below. There are several other memory measurements that you can use here. But, I am not quite sure whether there is a way to get the memory usage by thread. Process has Threads property which consists of a collection of ProcessThreads which is exactly what you are interested in, but not straight forward way to get the memory usage.

// Get the current process.
Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();

// Gets the amount of physical memory allocated for the associated process.
long totalNumberOfBytesUsed = currentProcess.WorkingSet64;
于 2011-06-16T05:54:40.500 に答える