title: Windows Service Memory Usage Increases
body: <p>I have a windows service doing 3 scheduled jobs. First of them is sending an email to employees their shift times. Second one is getting Active Directory information and saving it to local database. Last one is saving active directory photos to file directory. </p>
  
  <p>Each job is done on a separate thread. Timer ticks every 45 seconds. Everything is running perfectly except the memory usage by the service which is increasing steadily. </p>
  
  <p>Do you have any idea what might be causing this?</p>
  
  <pre><code>Thread[] thread;
  
  protected override void OnStart(string[] args)
  {
      timer = new System.Timers.Timer();
      timer.AutoReset = true;
      timer.Enabled = true;
      timer.Interval = 1000 * 45;
      timer.Start();
      timer.Elapsed += Timer_Elapsed;
      servisList = new List&lt;IService&gt;() { new ShiftNotification(), new     ActiveDirectoryService(), new DirectoryPhotos() };
      thread = new Thread[servisList.Count];
  }
  
  private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  {
      try
      {
          for (int i = 0; i &lt; servisList.Count; i++)
          {
              if (thread[i] == null)
              {
                  if (TimeControl.CheckTime(DateTime.Now, servisList.ElementAt(i).sProps))
                  {
                      thread[i] = new System.Threading.Thread(new System.Threading.ThreadStart(servisList.ElementAt(i).NotifyUsers));
                      thread[i].Start();
                  }
              }
              else
              {
                  if (thread[i].ThreadState != System.Threading.ThreadState.Running)
                  {
                      if (TimeControl.CheckTime(DateTime.Now, servisList.ElementAt(i).sProps))
                      {
                          thread[i] = new System.Threading.Thread(new System.Threading.ThreadStart(servisList.ElementAt(i).NotifyUsers));
                          thread[i].Start();
                      }
                  }
              }
          }
      }
      catch (Exception ex)
      {
      }
  }
  </code></pre>