Click to See Complete Forum and Search --> : Using the Windows Task Manager
Avayi
December 2nd, 2004, 08:24 AM
Hi Folks,
I am trying to debug a VC++ implemented application which I believe is leaking Handles (specifically Win32 Events). I am using Process Explorer and Windows Task Manager to identify and count the Event handles.
My problem is that the number of Event handles I see displayed within Task Manager and Process Explorer is a lot more than the Events actually created programmatically within the application code.
Does anyone know where these extra Event handles are coming from ? Process Explorer actually lists these extra handles as "unnamed".
Thanks in advance for your help.
Avayi.
Mutilated1
December 2nd, 2004, 02:45 PM
Windows creates those handles while running your program. You are right, they probably aren't handles your application created. Why do you think you are leaking handles ?
Avayi
December 3rd, 2004, 02:52 AM
I suspect a handle leak because when ever I keep the application (a modem handler by the way) running for a long time, the handle count increases progressively.
When I first start the application, the handle count is 53. When I use it to drive the modem by making a request to the modem, the handle count goes up to 58. This I can perfectly understand.
But when I terminate the request, and bring the application back to its original (i.e non-requesting) state, I expect (maybe naively) the handle count to drop back to 53. Instead, the handle count drops to 54. This "quiescent" handle count increases progressively after completing subsequent modem requests.
Arjay
December 3rd, 2004, 12:41 PM
But when I terminate the requestHow are you terminating the request? Are you closing the handles properly? Are you calling appropriate cancel functions or just terminating a thread?
Arjay
Avayi
December 4th, 2004, 08:38 AM
How are you terminating the request? Are you closing the handles properly? Are you calling appropriate cancel functions or just terminating a thread?
Arjay
I think I am closing the threads correctly. I terminate the request using CloseHandle(), and setting the handle to NULL immeadiately afterwards.
Arjay
December 6th, 2004, 12:43 PM
I think I am closing the threads correctly. I terminate the request using CloseHandle(), and setting the handle to NULL immeadiately afterwards.Um, there may be some confusion here. If you are using CloseHandle() on a thread, this won't make the thread finish. It just releases the handle so you can't use that handle anymore to suspend the thread or check its exit status. Understand that the thread will continue to operate unless you reach the end of the thread or you explicitly return early.
On the other hand, "I terminate the request using CloseHandle()...". Are you referring to a Win32 operation? If so, are you sure this is the correct way to cancel this operation? If not, this could be the source of the leak.
Arjay
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.