문제

I understand that .net threads are pretty heavy weight, consuming ~1MB of memory each (mostly for the stack). Now, if this was a user .net class I know that it is likely going to put most of the memory into LOH. However, since it is a core class, I am wondering what the behavior is.

The reason for this question is because I am memory profiling an (potentially long lived) application at the moment, and there seems to be a slow leak. I had noticed that VS is showing 33 threads (in various states, included stopped). I am wonder if the frugal usage of threads could be fragmenting the memory (along with a few LOH DTOs).

도움이 되었습니까?

해결책

The thread's stack is not stored on the LOH because the stack is not a CLR object. The thread's stack is allocated by the operating system when .NET asks for a new thread.

A CLR thread is a thin wrapper around an operating system thread.

If you really do have a memory leak, you can be sure that it's not in the thread objects themselves.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top