handle leaks..?

From: vinod kumar (naga_vinod_at_yahoo.com)
Date: 03/02/04


Date: Tue, 2 Mar 2004 13:03:47 +0530

Hi all,

It works fine on XP Professional but not on WinNT 4.0 and Win2k.
While PrivateBytes, VirtualBytes,etc doing very fine I see Handle count keep
going
up in the Task Manger and PerfMon.
Its about handle leaks but I wonder if anything special about winnt 4.0 and
win2k. In the
NT Service I'm creating threads in a loop, threads return fine and I do
close handles using CloseHandle() in a loop. And the return value of
CloseHandle() for all the handles looks fine (as viewed using
OutputDebugString() in the debugger and WaitForMultipleObjects always is
WAIT_OBJECT_0)

for(i = 0;i<z;i++)
{
array[i] = CreateThread(0,
     0, // use default stack size
     (LPTHREAD_START_ROUTINE) ThreadProc, // thread function
       NULL, // argument to thread function
      0, // use default creation flags
      &dwThreadID);
}

 DWORD waitfor = WaitForMultipleObjects(noofprocess,hThread,TRUE,freq);
 int relhandles = 0;

 switch(waitfor)
 {
  char clip[512];
  BOOL close;

 case WAIT_TIMEOUT:
  OutputDebugString(_T(" WAIT_TIMEOUT"));
  for(relhandles = 0; relhandles < curIns; relhandles++)
  {
   if(hThread[relhandles] !=0)
   {

    close = CloseHandle(hThread[relhandles]);

    if(close != 0)
    {
     sprintf(clip,_T("\n Handle %d closed \n"),relhandles);
     OutputDebugString(clip);
    }
    else
    {
     sprintf(clip,_T("\n Close Handle %d failed \n"),relhandles);
     OutputDebugString(clip);
     _Module.LogEvent(_T(clip));
    }
   }
  }
  break;

 case WAIT_ABANDONED_0:

  OutputDebugString(_T("WAIT_ABANDONED"));
  break;

 case WAIT_OBJECT_0:
  OutputDebugString(_T("WAIT_OBJECT_0"));

  for(relhandles = 0; relhandles < curIns; relhandles++)
  {
   if(hThread[relhandles] !=0)
   {

    close = CloseHandle(hThread[relhandles]);

    if(close != 0)
    {
     sprintf(clip,_T("\n Handle %d closed \n"),relhandles);
     OutputDebugString(clip);
    }
    else
    {
     sprintf(clip,_T("\n Close Handle %d failed \n"),relhandles);
     OutputDebugString(clip);
     _Module.LogEvent(_T(clip));
    }
   }
  }
break;
  default:
  OutputDebugString(_T("default"));

 }

thank you,
vinod



Relevant Pages

  • Handle leaks...
    ... It works fine on XP Professional but not on WinNT 4.0 and Win2k. ... PrivateBytes, VirtualBytes,etc doing very fine I see Handle count keep going ... NT Service I'm creating threads in a loop, threads return fine and I do ... CloseHandle() for all the handles looks fine (as viewed using ...
    (microsoft.public.vc.atl)
  • Re: install says copied files missing/corrupt
    ... hardware's working with Win98, is absolutely *NO* indication of its ... suitability for use with WinNT, Win2K, or WinXP. ...
    (microsoft.public.windowsxp.setup_deployment)
  • RE: directory traversal
    ... is some sort of overflow. ... (Running cmd.exe on Win2k) ... > C:\>cd winnt ... > Send FREE Valentine eCards with Yahoo! ...
    (Vuln-Dev)
  • GRUB with RH9 / Win2k / WinNT 4?
    ... I just installed RH9 on my machine and I'd like to have that reside along ... with Win2k and WinNT 4. ... Partition 1: Win2k ... think of but it always boots to Win2k. ...
    (linux.redhat)
  • Re: Supporting ATL
    ... shipped with, say, Win98 or WinNT out of the box. ... Win2K either, but I'm not sure. ... With sufficient thrust, pigs fly just fine. ...
    (microsoft.public.vc.atl)