Handle Leak on Windows 2003 Server x64



I have a C++ WMI application that seems to be causing a handle leak on
Windows 2003 Server x64. The same application running on Windows XP
and Windows 2003 Server 32-bit doesn't exhibit any handle leaks (I
have the application running 24x7 on four XP SP2 machines and two 2003
32-bit machines without leaks). Are there any known issues specific to
Windows 2003 x64 that would cause a handle leak?

I've verified the handle leak by looking at the handle count steadily
increasing with time. It goes from ~200 to ~10,1000 over the span of
two days or so. The data is being pulled from:



Win32_PerfFormattedData_PerfOS_Processor
Win32_PerfFormattedData_PerfProc_Process
Win32_PerfFormattedData_PerfDisk_PhysicalDisk
Win32_PerfFormattedData_Tcpip_NetworkInterface



Couple of things I've found while trying to figure out this problem:

- If I stop collection from Win32_PerfFormattedData_PerfOS_Processor
(while letting the collection go on from the other classes), the
handle leak seems to be drastically reduced or pretty much stop.
There's no specific logic in the application to handle
Win32_PerfFormattedData_PerfOS_Processor. The code is pretty generic.
The system on which the leak occurs is an AMD x64 system with a single
physical CPU / dual cores.

- The reason I disabled Win32_PerfFormattedData_PerfOS_Processor was
because using Process Explorer, I found tens of registry keys open to
HKLM\SYSTEM\ControlSet001\SERVICES\PerfOS\Performance. I assume this
to be the source of leak. The program doesn't have any interactions
with the registry directly.



The main loop of the program is basically:

while(1)
{
IWbemRefresher::Refresh()
IWbemHiPerfEnum::GetObjects()

if(firstTime)
getPropertyHandles()


Read Values for each property
Sleep for a bit
}



Any ideas?


Thanks,
KS
.



Relevant Pages

  • Re: GDI Object leak when connected using mstsc?
    ... When you disconnect the active desktop is switched to the Disconnect desktop object, which is a dummy object that prevents rendering. ... A GDI handle leak occurs in Windows XP and in Windows Server 2003 when an application frequently calls the CreateRectRgn function ... MFC applications leak GDI objects on computers that are running Windows XP ... I've discovered that if I run this program on the physical pc, the GDI objects remain constant. ...
    (microsoft.public.windows.terminal_services)
  • Re: How important is it to handle Memory Leaks
    ... In my program I am displaying some pattern on the ... 'Memory DC' inside those functions...and use it to just BitBlt to the main ... window when ever windows generates WM_PAINT. ... > it will cause leak if some other programmer enhances your program. ...
    (microsoft.public.win32.programmer.gdi)
  • RE: Windows 2000 SP
    ... How do you know TS is causing the leak? ... Gather perfmon logs on all counters all objects and try to track down which process may be leaking. ... | Content-Class: urn:content-classes:message ... | Subject: Windows 2000 SP ...
    (microsoft.public.win2000.advanced_server)
  • Re: Can an application hang Windows 2000?
    ... > upgrade, two of these PCs have hung, one after approx. ... The operating system is Windows 2000. ... The obvious question in mind is to look for a memory leak. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Memory leak in .NET service on Windows 2000
    ... I've seen timer leaks especially with short durations like yours but it was ... > service running on Windows 2000 platforms. ... > Windows Service and added a FileSystemWatcher and a Timer object. ... > disabled and this causes a significant memory leak on Windows 2000 ...
    (microsoft.public.dotnet.framework)