I use C# in VS 2008 framework 3.5 and VS2005 framework 2.0.
When I use system timer, I find in every several seconds it increases 8K memory usage and keep increasing as long as you wish. Here is the code. You can cut and paste it in console application in either vs2008 or vs2005, compile and run it. Then you can observe the memory increase. Does anyone have a solution or work around?
Using System;
using System.Timers;
publicclassTimer1
{
publicstaticvoid Main()
{
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += newElapsedEventHandler(OnTimedEvent);
aTimer.Interval =75;
aTimer.Enabled = true;
Console.WriteLine("Press the Enter key to exit the program.");
Console.ReadLine();
GC.KeepAlive(aTimer);
}
privatestaticvoid OnTimedEvent(object source, ElapsedEventArgs e)
{
Console.WriteLine("Hello World!");
}
}