Problem:
If a COBOL Application is called from a C DLL in a multithreaded environment then the C needs to call cobthreadtidy() when it will no longer call any COBOL from that thread. This will allow the COBOL runtime to free any Thread Local Storage that has been allocation and hence stop any memory leaks from occuring.
In some applications it is difficult to determine when to call cobthreadtidy.
Resolution:
In the C DLL that called COBOL you could call cobthreadtidy() from DLLMAIN on DLL_THREAD_DETACH. This would alleviate the need for any logic to determine when that last COBOL Call had taken place.
DLL_THREAD_DETACH in DLLMAIN will be called then the thread is exiting cleanly and it is called on the thread that is terminating.
Please see the Microsoft Platform SDK for more information on DLLMAIN.