I have a medium-sized process viewer which uses around ~40MB of private memory on Windows Vista. The problem is that people always compare this number to the amount of memory used by Process Explorer and similar, unmanaged tools.
I've noticed that when my program is idle, there are 13 running threads:
- One RPC thread (RPCRT4.dll!ThreadStartRoutine)
- One COM-related thread (ole32.dll!CoRegisterSurrogateEx+0x35e0)
- Two ntdll threads (ntdll.dll!TppWorkerThread, ntdll.dll!TppWaiterpThread)
- The main GUI thread
- A timer thread (used by the CLR)
- The gate thread (CLR)
- The debugger thread (CLR)
- 4 worker threads (mscorwks.dll!Thread::intermediateThreadProc)
- And finally a GDI+ background thread (gdiplus.dll!BackgroundThreadProc)
How can I get rid of some of these threads, freeing thread stack memory (1MB each)? ThreadPool.GetAvailableThreads tells me that there are 0 worker threads running, but there are 3 "intermediateThreadProc" threads. Could using the service manager API have anything to do with the RPC thread? (It makes RPC calls.)