title: Resolving Error R6016 - Not enough space for thread data
body: <p>My statically-linked Visual C++ 2012 program sporadically generates a CRTL error: "R6016 - Not enough space for thread data".</p>
  
  <p>The minimal documentation from Microsoft says this error message is generated when a new thread is spawned, but not enough memory can be allocated for it.</p>
  
  <p>However, my code only explicitly spawns a new thread in a couple of well-defined cases, neither of which are occurring here (although certainly the Microsoft libraries internally spawn threads at well).  One user reported this problem when the program was just existing in the background.  </p>
  
  <p>Not sure if it's relevant, but I haven't overridden the default 1MB reserved stack size or heap size, and the total memory in use by my program is usually quite small (3MB-10MB on a system with 12GB actual RAM, over half of which is unallocated).</p>
  
  <p>This happens very rarely (so I can't track it down), and it's been reported on more than one machine. I've only heard about this on Windows 8.1, but I wouldn't read too much into that.</p>
  
  <p>Is there some compiler setting somewhere that might influence this error?  Or programming mistake?</p>