473,397 Members | 1,950 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,397 software developers and data experts.

Memory leak in ManagementObject ..?

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 ManagementObject 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 ManagementObject.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_timerGetCPUInfo
private ManagementObject[] arrCPUObjects
private int nCPUs = 2

public MyForm(

ManagementScope managementScope = new ManagementScope()
arrCPUObjects = new ManagementObject[nCPUs]

ManagementPath mPath_CPU = new ManagementPath()

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

mPath_CPU.RelativePath = "Win32_PerfRawData_PerfOS_Processor.Name='" + i + "'"

arrCPUObjects[i] = new ManagementObject(managementScope,mPath_CPU,null)
m_timerGetCPUInfo = new System.Windows.Forms.Timer()
m_timerGetCPUInfo.Tick += new EventHandler(CheckStatusTimer)
m_timerGetCPUInfo.Interval = 500
m_timerGetCPUInfo.Start()
private void CheckStatusTimer(object sender, System.EventArgs e

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

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

arrCPUObjects[i].Get()

ulong temp1 = (ulong)arrCPUObjects[i].Properties["PercentProcessorTime"].Value
ulong temp2 = (ulong)arrCPUObjects[i].Properties["TimeStamp_Sys100NS"].Value
}
Jul 21 '05 #1
0 1613

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...
1
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...
3
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...
0
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...
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
7
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...
1
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...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...

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.