Hello, 

Our service reads some data from archive each minute (using Thread). But when this service is running, Runtime memory increases continuously.
Could someone help me to detect, what is wrong with this part of code:


    public class ServiceExtension : IProjectServiceExtension
    {
        Thread t1;
        public void Start(IProject context, IBehavior behavior)
        {
            t1 = new Thread(() => Calculation(context));
            t1.Priority = ThreadPriority.Highest;
            t1.Start();
        }
        public void Calculation(IProject context)
        {
            IRuntimeArchive RuntimeArchive = null;
            IEnumerable<IRuntimeArchiveVariable> ArchiveVariables = null;
            IRuntimeArchiveVariable ArchiveVariable = null;

            while (true){
                try{
                    //Gets necessary archive of the project                             
                    RuntimeArchive = (from X in context.RuntimeArchiveCollection where X.Name == "1MIN_1D" select X).First();

                    if (RuntimeArchive == null){
                        Debug.Print("No archive available!");
                        return;
                    }

                    //Gets variables
                    ArchiveVariables = (from X in RuntimeArchive.VariableCollection where X.Name.Contains(".ActivePower") && X.AggregationType.ToString().Contains("Average") select X);

                    foreach (var item in ArchiveVariables){
                        ArchiveVariable = null;

                        //Get variables
                        ArchiveVariable = (from X in RuntimeArchive.VariableCollection where X.Name != null && X.Name == "ActivePower" select X).FirstOrDefault();

                        //some logic
                        //........
                    }
                }
                catch (Exception e){
                    Debug.Print(e.ToString());
                }

                //Wait at least 1min
                Thread.Sleep(60000);
            }
        }
    }


Thanks!