I've seem to have a memory leak. I found a post on stackoverflow recommending 'using' method but this doesn't seem to fix the issue.
I am using Red Gate memory profiler which shows an increase in unmanaged memory constantly rising.
This is the simple application I made to test:
namespace TimerDebug
{
public partial class TimerDebug : ServiceBase
{
public TimerDebug()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
// Create Timer
Timer MyTimer = new Timer(500);
MyTimer.Elapsed += MyTimer_Elapsed;
// Start Timer
MyTimer.Start();
}
void MyTimer_Elapsed(object sender, ElapsedEventArgs e)
{
using (var C = new OdbcConnection("Dsn=MyFireReport;"))
{
C.Open();
}
OdbcConnection.ReleaseObjectPool();
}
protected override void OnStop()
{
}
}
}
Does anybody know how to fix this? Thanks.