473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

wmi memory leak?

cs
if I repeatedly call the following method on my winxp machine (and many
others) the svchost.exe process increases its memory very very quickly, and
doesnt go back donw, I have machines that after a day have svchosts taking 1
gig of ram, thank god I have 3 more to spare!

public static void GetNetworkProperties(String NetConnectionID)

{
try

{

SelectQuery sq = new SelectQuery("select * from Win32_NetworkAdapter where
NetConnectionID=\""+NetConnectionID+"\"");

ManagementObjectSearcher mos = new ManagementObjectSearcher(sq);
foreach(ManagementObject mo in mos.Get())

{
foreach(PropertyData data in mo.Properties)

{
if(data.Name.Equals("Index"))

{

ManagementObjectSearcher query1 = new ManagementObjectSearcher("SELECT
DefaultIPGateway,IPAddress,DNSServerSearchOrder,DH CPEnabled,IPSubnet,MACAddr
ess FROM Win32_NetworkAdapterConfiguration where Index="+data.Value);

ManagementObjectCollection queryCollection = query1.Get();

String[] ips = null;

String[] dns = null;

bool dhcp = false;

String[] subnet = null;

String mac = null;

String[] gateway = null;

foreach(ManagementObject adapter in queryCollection)

{

foreach(PropertyData prop in adapter.Properties)

{
switch(prop.Name)

{

case "IPAddress":

if ( prop.Value != null)

{

ips = (String[])prop.Value;
}

break;

case "DNSServerSearchOrder":

if ( prop.Value != null)

{

dns = (String[])prop.Value;
}

break;

case "DHCPEnabled":

if ( prop.Value != null)

{

dhcp = Convert.ToBoolean(prop.Value);

}

break;

case "IPSubnet":

if ( prop.Value != null)

{

subnet = (String[])prop.Value;
}

break;

case "MACAddress":

if ( prop.Value != null)

mac = prop.Value.ToString();

break;

case "DefaultIPGateway":

if ( prop.Value != null)

{

gateway = (String[])prop.Value;
}

break;

}

}

}
}

}
}

}

catch(Exception exe)

{
}
}
Nov 15 '05 #1
1 3234
Check this KB article "Memory Leak When You Use the Win32_NetworkAdapter
Notification Query" KB 824262
Willy.

"cs" <[rem]casolorz[rem]@hot[rem]mail.com> wrote in message
news:uv**************@TK2MSFTNGP10.phx.gbl...
if I repeatedly call the following method on my winxp machine (and many
others) the svchost.exe process increases its memory very very quickly,
and
doesnt go back donw, I have machines that after a day have svchosts taking
1
gig of ram, thank god I have 3 more to spare!

public static void GetNetworkProperties(String NetConnectionID)

{
try

{

SelectQuery sq = new SelectQuery("select * from Win32_NetworkAdapter where
NetConnectionID=\""+NetConnectionID+"\"");

ManagementObjectSearcher mos = new ManagementObjectSearcher(sq);
foreach(ManagementObject mo in mos.Get())

{
foreach(PropertyData data in mo.Properties)

{
if(data.Name.Equals("Index"))

{

ManagementObjectSearcher query1 = new ManagementObjectSearcher("SELECT
DefaultIPGateway,IPAddress,DNSServerSearchOrder,DH CPEnabled,IPSubnet,MACAddr
ess FROM Win32_NetworkAdapterConfiguration where Index="+data.Value);

ManagementObjectCollection queryCollection = query1.Get();

String[] ips = null;

String[] dns = null;

bool dhcp = false;

String[] subnet = null;

String mac = null;

String[] gateway = null;

foreach(ManagementObject adapter in queryCollection)

{

foreach(PropertyData prop in adapter.Properties)

{
switch(prop.Name)

{

case "IPAddress":

if ( prop.Value != null)

{

ips = (String[])prop.Value;
}

break;

case "DNSServerSearchOrder":

if ( prop.Value != null)

{

dns = (String[])prop.Value;
}

break;

case "DHCPEnabled":

if ( prop.Value != null)

{

dhcp = Convert.ToBoolean(prop.Value);

}

break;

case "IPSubnet":

if ( prop.Value != null)

{

subnet = (String[])prop.Value;
}

break;

case "MACAddress":

if ( prop.Value != null)

mac = prop.Value.ToString();

break;

case "DefaultIPGateway":

if ( prop.Value != null)

{

gateway = (String[])prop.Value;
}

break;

}

}

}
}

}
}

}

catch(Exception exe)

{
}
}

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? ...
17
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is...
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
23
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
22
by: Peter | last post by:
I am using VS2008. I have a Windows Service application which creates Crystal Reports. This is a multi theaded application which can run several reports at one time. My problem - there is a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.