Hi All.
I created a simple application that monitors values coming from single tag.
It subscribes to tag value changes via pisdk pipe.
The main problem is that after some period of time (after one day) the running executable memory growing twice.
The application crashed one week after it started because of out of memory exception.
I used ISlimFast and IRefresh interfaces to reduce memory size but nothing helped.
Here is an example of the application:
class Program { private static PISDK.PISDK _pisdk = null; private static PISDK.IEventPipe2 _eventPipe = null; static void Main(string[] args) { _pisdk = new PISDK.PISDK(); PISDK.Server piServer = _pisdk.Servers["XXX"]; piServer.Open("UID=IDXXX"); Monit(piServer, "tag='SOME_TAG_NAME'"); Console.WriteLine("Start monitoring..."); Console.WriteLine("Press ENTER to exit the application."); Console.ReadLine(); } public static void Monit(PISDK.Server piServer, string filter) { PISDK.PointList pointList = piServer.GetPoints(filter); if (pointList == null || pointList.Count == 0) { pointList = null; return; } _pisdk.Refresh(pointList); _eventPipe = pointList.Data.EventPipe as PISDK.IEventPipe2; ((PISDK._DEventPipeEvents_Event)pointList.Data.EventPipe).OnNewValue += new PISDK._DEventPipeEvents_OnNewValueEventHandler(() => { try { if (_eventPipe.Count == 0) return; Array eventsArray = _eventPipe.TakeAll(); for (int i = 0; i < eventsArray.Length; ++i) { PISDK.PIEventObject newEvent = (PISDK.PIEventObject)eventsArray.GetValue(i); PISDK.PointValue pointValue = newEvent.EventData as PISDK.PointValue; string tagName = pointValue.PIPoint.Name; string value = pointValue.PIValue.Value as string; string time = pointValue.PIValue.TimeStamp.LocalDate.ToString("dd-MMM-yyyy HH:mm:ss"); Console.WriteLine("Point:{0}, Value:{1}, TimeStamp:{2}", tagName, value, time); tagName = null; value = null; time = null; pointValue = null; newEvent = null; eventsArray.SetValue(null, i); } eventsArray = null; ((PISDKCommon.ISlimFast)piServer).SlimFast(); } catch (Exception exp) { Console.WriteLine("Error: {0}", exp.Message); } }); } }
Can someone assist me with this issue?
Thanks!