_beginthread/_beginthreadex allocates memory per thread that is not properly free:d under Windows XP.
The provided program will report leaks of ~1Kb/thread when built with a statically linked CRT and the v140_xp toolchain (Change the THREAD_COUNT for more threads and leaks).
It does not seem to leak under VS2013.
This seems to be related to the fact that the UCRT (used by VS2015) no longer free:s the memory allocated per thread in _endthread/_endthreadex but instead relies on
DLL_THREAD_DETACH messages to DllMain which doesn't seem to propagate properly with a statically linked CRT in Windows XP.