473,800 Members | 2,507 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Memory leak in ManagementObjec t ..?

Memory leak and .NET -- like oil and water :-

I've written a distributed system for parallel processing of large tasks. Each machine has an agent on it that sends processor usage information back to the controlling apps so that tasks can be distributed based on current system load. Obviously I need to do this on a timer, so that I always have current CPU utilization info ... The problem is that I can't seem to stop my agent's memory usage from getting out of hand, and am beginning to think this is a bug in the implementation of the ManagementObjec t class

a code example is below ... I obviously cut out all of the boilerplate windows form initialization code here, but I think you can get the point... The memory leak occurs in the call to ManagementObjec t.get(). I'd be more than happy to explicitly clean up the memory, but can't seem to find any methods that accomplish that

Any advice would be appreciated, or a link to some really cheap memory !! :-

public class MyForm : System.Windows. Forms.For

private System.Windows. Forms.Timer m_timerGetCPUIn fo
private ManagementObjec t[] arrCPUObjects
private int nCPUs = 2

public MyForm(

ManagementScope managementScope = new ManagementScope ()
arrCPUObjects = new ManagementObjec t[nCPUs]

ManagementPath mPath_CPU = new ManagementPath( )

for(int i=0;i<nCPUs;i++

mPath_CPU.Relat ivePath = "Win32_PerfRawD ata_PerfOS_Proc essor.Name='" + i + "'"

arrCPUObjects[i] = new ManagementObjec t(managementSco pe,mPath_CPU,nu ll)
m_timerGetCPUIn fo = new System.Windows. Forms.Timer()
m_timerGetCPUIn fo.Tick += new EventHandler(Ch eckStatusTimer)
m_timerGetCPUIn fo.Interval = 500
m_timerGetCPUIn fo.Start()
private void CheckStatusTime r(object sender, System.EventArg s e

//------------------------------------------------------/
// Start memory eating loop !! :-
//------------------------------------------------------/

for(int i=0;i<nCPUs;i++

arrCPUObjects[i].Get()

ulong temp1 = (ulong)arrCPUOb jects[i].Properties["PercentProcess orTime"].Value
ulong temp2 = (ulong)arrCPUOb jects[i].Properties["TimeStamp_Sys1 00NS"].Value
}
Jul 21 '05 #1
0 1665

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

Similar topics

8
3414
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
4818
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...
1
3255
by: cs | last post by:
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) {
3
4588
by: beattie.stuart | last post by:
I think I've found a memory leak trying to use the system.management.ManagementObject, but it could be my programming skills so I'd appreciate some advice. I've writing a monitoring routine that queries WMI for some stats, but it continually eats into memory. I've cut the code down to the following sample but the problem is still there: Imports System Imports System.Management
0
331
by: Brian Piscopo | last post by:
Memory leak and .NET -- like oil and water :- I've written a distributed system for parallel processing of large tasks. Each machine has an agent on it that sends processor usage information back to the controlling apps so that tasks can be distributed based on current system load. Obviously I need to do this on a timer, so that I always have current CPU utilization info ... The problem is that I can't seem to stop my agent's memory usage...
23
4575
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
7
6937
by: Salvador | last post by:
Hi, I am using WMI to gather information about different computers (using win2K and win 2K3), checking common classes and also WMI load balance. My application runs every 1 minute and reports the status of the machines. Upon we follow the .NET object lifetime recommendations the application is constantly consuming more memory! The problem is on the ManagementObjectSearch, upon we Dispose the object it seems that is not releasing the...
1
1716
by: J | last post by:
Hi, I've written a multi threaded application which scans about 2000 servers event logs to check for disk errors. The problem with it is due to the fact that it just keeps eating memory. In the end it's used up the best part of 100Mb, which I think is excessive. For each server it checks, it creates a new EventHelper object and
22
9368
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
9551
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
10274
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
10251
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
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7576
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
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
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.