473,811 Members | 2,788 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 GetNetworkPrope rties(String NetConnectionID )

{
try

{

SelectQuery sq = new SelectQuery("se lect * from Win32_NetworkAd apter where
NetConnectionID =\""+NetConnect ionID+"\"");

ManagementObjec tSearcher mos = new ManagementObjec tSearcher(sq);
foreach(Managem entObject mo in mos.Get())

{
foreach(Propert yData data in mo.Properties)

{
if(data.Name.Eq uals("Index"))

{

ManagementObjec tSearcher query1 = new ManagementObjec tSearcher("SELE CT
DefaultIPGatewa y,IPAddress,DNS ServerSearchOrd er,DHCPEnabled, IPSubnet,MACAdd r
ess FROM Win32_NetworkAd apterConfigurat ion where Index="+data.Va lue);

ManagementObjec tCollection queryCollection = query1.Get();

String[] ips = null;

String[] dns = null;

bool dhcp = false;

String[] subnet = null;

String mac = null;

String[] gateway = null;

foreach(Managem entObject adapter in queryCollection )

{

foreach(Propert yData prop in adapter.Propert ies)

{
switch(prop.Nam e)

{

case "IPAddress" :

if ( prop.Value != null)

{

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

break;

case "DNSServerSearc hOrder":

if ( prop.Value != null)

{

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

break;

case "DHCPEnable d":

if ( prop.Value != null)

{

dhcp = Convert.ToBoole an(prop.Value);

}

break;

case "IPSubnet":

if ( prop.Value != null)

{

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

break;

case "MACAddress ":

if ( prop.Value != null)

mac = prop.Value.ToSt ring();

break;

case "DefaultIPGatew ay":

if ( prop.Value != null)

{

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

break;

}

}

}
}

}
}

}

catch(Exception exe)

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

"cs" <[rem]casolorz[rem]@hot[rem]mail.com> wrote in message
news:uv******** ******@TK2MSFTN GP10.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 GetNetworkPrope rties(String NetConnectionID )

{
try

{

SelectQuery sq = new SelectQuery("se lect * from Win32_NetworkAd apter where
NetConnectionID =\""+NetConnect ionID+"\"");

ManagementObjec tSearcher mos = new ManagementObjec tSearcher(sq);
foreach(Managem entObject mo in mos.Get())

{
foreach(Propert yData data in mo.Properties)

{
if(data.Name.Eq uals("Index"))

{

ManagementObjec tSearcher query1 = new ManagementObjec tSearcher("SELE CT
DefaultIPGatewa y,IPAddress,DNS ServerSearchOrd er,DHCPEnabled, IPSubnet,MACAdd r
ess FROM Win32_NetworkAd apterConfigurat ion where Index="+data.Va lue);

ManagementObjec tCollection queryCollection = query1.Get();

String[] ips = null;

String[] dns = null;

bool dhcp = false;

String[] subnet = null;

String mac = null;

String[] gateway = null;

foreach(Managem entObject adapter in queryCollection )

{

foreach(Propert yData prop in adapter.Propert ies)

{
switch(prop.Nam e)

{

case "IPAddress" :

if ( prop.Value != null)

{

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

break;

case "DNSServerSearc hOrder":

if ( prop.Value != null)

{

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

break;

case "DHCPEnable d":

if ( prop.Value != null)

{

dhcp = Convert.ToBoole an(prop.Value);

}

break;

case "IPSubnet":

if ( prop.Value != null)

{

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

break;

case "MACAddress ":

if ( prop.Value != null)

mac = prop.Value.ToSt ring();

break;

case "DefaultIPGatew ay":

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
3418
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 ? In nut shell, what is/are the realtion/s between the Memory Leak and Memory Corruption. Juts Theoritical Assumtion below:
17
4821
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 easier to reproduce (e.g.: remote machine not available). After about 1 day, I get a usage of 300MB of memory. I have used .NET Memory Profiler tool to try to see where the leak is located. For all the leaky instances, I can see the following (I...
20
8122
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 matches are called within a loop (like if or for). E.g. for(int i = 0; i < 10; i++) { Regex r = new Regex();
23
4580
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
9370
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 memory leak someplace. I can not detect the memory leak by running several reports by hand, but when I run tha app as a servrice and process few hundred reports there is significant memory leak. The application can consume over 1GB of memory where it...
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10663
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10401
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10416
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9217
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7676
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4357
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.