views:

37

answers:

1

Hi, I am building a .NET windows service which is using an unmanaged C++ dll. both of my service and the c++ dll are using multi threading. I am running out of memory after some time (hours) while processing. I tried to measure the number of threads using "Performance counters" and I monitors the following values:

# of current logical Threads
# of current recognized threads
# of total recognized Threads

While the first one is steady and its value is reasonable the 2nd and the 3rd are not. they are always growing and reaching a huge number (over 1500). And they are equal !!!!

Should they be equal? I also didn't understand from this page if those counters will count both managed and unmanaged threads.

I suspect that the unmanaged code is alwayes launching new threads instead of reusing them, but I am not sure.

can anyone help? Thanks

A: 

Sounds like a leak. Most likely the unmanaged DLL is not properly disposing of it's threads.

In order to really test this write a single threaded app which uses that DLL. Monitor the app. If you notice it's not disposing of things properly, then you have one of two situations.

Either you aren't calling the correct methods in the DLL to close the resources (threads). Or the DLL is badly coded. The first one is easy to fix, the second one will require access to the source code or original developers.

If it is the DLL and you can't contact them or they are unwilling to fix, then find something else that does nearly the same thing.

Chris Lively
Great, I did as you suggested (made a single threaded app which uses that DLL in a loop) and I still see increment in both:# of current recognized threads# of total recognized Threadsand they are always equalWhat does that mean?
TB
It means either the dll isn't freeing it's own resources or there is a function call in the dll that you aren't making. I would bet on the former. If it is the former then you need to contact whoever built the dll and see if there is an update or find another product that does the same thing.
Chris Lively