CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2004
    Posts
    3

    Unhappy Using the Windows Task Manager

    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.

  2. #2
    Join Date
    May 2004
    Location
    Pell City, Alabama
    Posts
    126

    Re: Using the Windows Task Manager

    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 ?

  3. #3
    Join Date
    Dec 2004
    Posts
    3

    Re: Using the Windows Task Manager

    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.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Using the Windows Task Manager

    Quote Originally Posted by Avayi
    But when I terminate the request
    How are you terminating the request? Are you closing the handles properly? Are you calling appropriate cancel functions or just terminating a thread?

    Arjay

  5. #5
    Join Date
    Dec 2004
    Posts
    3

    Re: Using the Windows Task Manager

    Quote Originally Posted by Arjay
    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.

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Using the Windows Task Manager

    Quote Originally Posted by Avayi
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured