Tuesday, February 24, 2009

Expensive Thread creation

 

Creating a thread involves following points :

  • Allocate and initialize a thread kernel object
  • each thread gets 1MB of address space – user stack
  • each thread gets 12KB of address space – kernel stack
  • notify every DLL about the newly created thread
  • notify every DLL when a thread is destroyed
  • free kernel object and the stacks

All this is pretty expensive as against ThreadPool, in ThreadPool, CLR doesn’t create (except for the 1st time) or destroy (except under idle condition) threads

No comments: