S
Sebastian Sosna
Hello NG,
iam having a problem with the code block below. All what i do is to
trace processes that exited. Iam using a 5 sec timer to call the
following Method:
(wich i think is causing the leak)
private void GetRunningProcesses(){
System.Diagnostics.Process[] p =
System.Diagnostics.Process.GetProcesses();
for(int i = 0; i<p.Length ; i++){
p.EnableRaisingEvents = true;
p.Exited += new System.EventHandler(MyProcess_Exited);
}
p = null;
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
}//end
The Method is running in a service. Onstart i call the timer to call
TimerCallbackProc in a 5 sek intervall like this:
OnStart(){
Proctimer = new System.Timers.Timer(5000);
Proctimer.Elapsed+=new
System.Timers.ElapsedEventHandler(TimerCallbackProc);
Proctimer.Enabled=true;
}
The timer callback is triggering GetRunningProcesses()
private void TimerCallbackProc(object source,
System.Timers.ElapsedEventArgs e)
{
GetRunningProcesses();
}
There is no other code wich iam calling in the service only the
methods you see, but still the application is growing and not freeing
any memory!
Can anybody tell me what iam doing wrong? As i said the code is
running in a service and keeps growing in memory usage
thanks for advice
regards Sebastian
iam having a problem with the code block below. All what i do is to
trace processes that exited. Iam using a 5 sec timer to call the
following Method:
(wich i think is causing the leak)
private void GetRunningProcesses(){
System.Diagnostics.Process[] p =
System.Diagnostics.Process.GetProcesses();
for(int i = 0; i<p.Length ; i++){
p.EnableRaisingEvents = true;
p.Exited += new System.EventHandler(MyProcess_Exited);
}
p = null;
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
}//end
The Method is running in a service. Onstart i call the timer to call
TimerCallbackProc in a 5 sek intervall like this:
OnStart(){
Proctimer = new System.Timers.Timer(5000);
Proctimer.Elapsed+=new
System.Timers.ElapsedEventHandler(TimerCallbackProc);
Proctimer.Enabled=true;
}
The timer callback is triggering GetRunningProcesses()
private void TimerCallbackProc(object source,
System.Timers.ElapsedEventArgs e)
{
GetRunningProcesses();
}
There is no other code wich iam calling in the service only the
methods you see, but still the application is growing and not freeing
any memory!
Can anybody tell me what iam doing wrong? As i said the code is
running in a service and keeps growing in memory usage

thanks for advice
regards Sebastian