I have a multithreaded application in C++ for Windows 7. This app is compiled as a DLL for the use of another C# app.
I run the multithreaded code for long hours to process streaming data. If I compile this C++ code into a stand-alone .exe, and run the code, it works fine.
But when it is turned into a DLL and when the C# code runs with it, the program crashes with Access Violation error after long runs. I see a similar crash when I load the DLL from a Python script and run it for long hours.
When I watch the behavior using Task Manager, I see the System Handle count increasing at a really rapid pace. After around 2 hours of code run, i see the handle count cross 300,000 mark and it keeps increasing.
Inside the multithreaded code, the threads are being created and teared down continuously. I see that after the thread is exited, the thread handle is not closed explicitly by an CloseHandle function. Could this be a potential problem?
How do I confirm that it is a handles issue. What are the ways to watch these system resources in a better way? Before I attempt any fixes, I would like to know all possible solutions as the test runs take a long time, more than 5 hours, to reproduce the crash.