Hi, all
We have an application with WMI query in a loop. We find occasionally memory leak on Vista 32 no_SP/SP1/SP2. When there is memory leak, there are hundreds of TCP connections in “Established�state with WMI port as target. (by netstat -an)
The code is like below
Class A
{
public ManagementScope scConnect;
public static DoWork
{
While(true)
{
scConnect = new ManagementScope(�;
scConnect.Connect();
�/span>
Thread.Sleep(5000);
}
}
}
This issue can only be re-produced on 1-2 of 10 test machines after 10 hours, but quite stably.
When we wrote a sample console application with precisely the same WMI behavior, the memory leak issue can not be re-producible and there is no pending TCP connection.
We tried to disconnect by set ManagementScope (scConnect) to be null as below code, however, we still find one leak among 10 after 1 night.
scConnect = null;
Any hint? Thanks in advance.
Jack