Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Calender memory leak.. (Read 4573 times)
trash2all
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Joined: Jul 17th, 2007
Calender memory leak..
Jan 17th, 2008 at 8:44am
Print Post  
hello,

I'm loading data to calender and have a memory leak!!!

my code is:
Code
Select All
using (DataTable dtMP = /* Get DataTable */)
{
    if (dtMP == null)
    {
	  // Ignore Operation!
	  return;
    }
    calendar.SuspendLayout();
    // Save reference to old Schedule
    Schedule oldSchedule = calendar.Schedule;
    oldSchedule.Clear();
    // Create new Schedule (remove old items)
    calendar.Schedule = new Schedule();
    // Release resources for old Schedule
    oldSchedule.Dispose();
    oldSchedule = null;

    int count = dtMP.Count;
    if (count == 0)
    {
	  calendar.ResumeLayout();
	  return;
    }
    Appointment appointment;
    DataRow rowMP;
    for (int i = 0; i < count; i++)
    {
	  rowMP = dtMP[i];

	  appointment = new Appointment();
	  appointment.StartTime = rowMP.StartTime;
	  appointment.EndTime = rowMP.EndTime;
	  appointment.Locked = true;
	  appointment.Tag = rowMP;
	  appointment.Style = m_style;

	  calendar.Schedule.Items.Add(appointment);
    }
    calendar.ResumeLayout();
}
 



I run this code every time i need to refresh calender's appointments.

i added the code in the of disposing for releasing resources.
Am i doing something wrong?

thanks in advance.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Calender memory leak..
Reply #1 - Jan 17th, 2008 at 11:24am
Print Post  
The code seems OK at first glance. Have you tried to call the GC.Collect method?

Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint