By carefully reading
you can see begin a thread created with _beginthreadex must be closed by _endthreadex. _beginthread can’t be used because “If the thread generated by _beginthread exits quickly, the handle returned to the caller of _beginthread might be invalid or, worse, point to another thread” (sight)
Secondly, _endthreadex doesn’t automatically close the created handle.
This is kind of problematic with the way juce implements it (much probably because of the win32 brilliant implementation).
when threadEntryProc calls _endthread the thread is already finished and there is no way to close the handle properly, so we had to write an ugly fix by using a static list of handles to close (…) I hope you’ll find a better way to do this.
To find handle leaks, you can use the task manager, and make it show the handle cound in the column selection dialog.
To find out more precisely what kind of handles these are you can use handle.exe :
you can use it this way :
handle.exe -s -p jucer
We found out there are other handle leaks, mostly Event handles, but we weren’t able to find out where these are from, cause it looks like every CreateEvent() call is matched with a CloseHandle()…