Rafik.Rezine

Issue in freeing AFValue objects - memory leak using AFSDK

Discussion created by Rafik.Rezine on May 23, 2011
Latest reply on Jun 20, 2011 by skwan
Hi, I am developing a .Net application reading periodically AF attributes values from a PI AF Server. I am using the GetValue() method of the AFAttributesList AF SDK object (containing 800 attributes).
When I run the application for some minutes (30 minutes to several hours), there is a clear memory leak in my application related to this instruction (repeated every 5 seconds).

My question is: how I can free the related memory?

Here is my code:

Declaration and initialization at the beginning of the program:
public AFAttributeList objAFAttributeList = null; public AFValues objAFValues = null;
objAFAttributeList = new AFAttributeList(); objAFValues = new AFValues();
block of instruction repeated
int iLength = 0;
lock (Program.myPIAFDatabase)
{
myPIAFDatabase.Refresh();
}
lock (objManager.objAFAttributeList)
{
objAFValues =objAFAttributeList.GetValue();
iLength = objAFValues.Count;
}
objAFValues.Clear();
objAFValues = null;

Outcomes