IvanBerry

Memory Leak calling PointList.Data.ArcValue

Discussion created by IvanBerry on Oct 19, 2012
Latest reply on Oct 22, 2012 by IvanBerry

I am seeing a significant memory leak calling the PointList.Data.ArcValue method.

 

I see there is a previous post on a related topic, but no resolution. Essentially the code below will run until it rapidly hits about 2GB of memory utilization, then it will crash. The purpose of this code is to extract data and pump it back into PI as a sort of simulator.

 

Any thoughts? Perhaps I have my project settings wrong?

 

This is with PI SDK 1.4.0.416, and I added the assemblies from here:

 

C:\Program Files\PIPC\PISDK\PublicAssemblies\OSIsoft.PISDK.dll

 

 

 

Code follows, I have taken out all the other code that could cause memory leaks and left just the call to ArcValues, the full project is attached as a zip file:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PISDK;

namespace CompressedData_ToFile
{
    class Program
    {
        [STAThread] 
        static void Main(string[] args)
        {

          
            int iterations = 486000;
            PISDK.PISDK sdk = new PISDK.PISDK();
            Server myserv = sdk.Servers["PISERVER"];
            PISDKCommon.NamedValues nvError = new PISDKCommon.NamedValues();
            PointList ptlist = new PointList();
            PointValues pvals;
   
            ptlist = myserv.GetPoints("tag='OPC_*'"); //this is about 1500 points

            DateTime ValueTime = System.DateTime.Parse("9/7/2012 5:00:00 PM");

            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();

            for (int i = 0; i < iterations; i++)
            {
                // Begin timing
                try
                {
                    stopwatch.Start();
                    
                    pvals = ptlist.Data.ArcValue(ValueTime, PISDK.RetrievalTypeConstants.rtAtOrAfter, out nvError);
   

                    
                    // Stop timing
                    stopwatch.Stop();

                    Console.Write("{0}% Complete, Finished Time {1} , interation {2} of {3}, last iteration took {4} ", (i / iterations)*100, ValueTime, i, iterations, stopwatch.Elapsed);
                    Console.SetCursorPosition(0, 0);
                    stopwatch.Reset();

                }
                catch
                {
                    Console.Write("ERROR: {0}% Complete, Finished Time {1} , interation {2} of {3}, last iteration took {4} ", i / iterations, ValueTime, i, iterations, stopwatch.Elapsed);
                }
                ValueTime = ValueTime.AddSeconds(1);
            }
            Console.WriteLine("Done");
        }



    }

}

 

 

 

 

 

 

 

 

 

 

Attachments

Outcomes