AnsweredAssumed Answered

PI AF SDK - FindElementsAttribute Memory Leak Issue

Question asked by Yasin@Cat on Sep 30, 2018
Latest reply on Oct 3, 2018 by Rick Davin

Hi All,

 

In my AF we have around 350 + Elements. To get all attributes, we are calling AFAttribute.FindElementAttributes method by passing element details (ie. FindElementAttributes method is called 350 times), which is currently consuming most of the RAM and Memory usage is not cleared after fetching all the attributes. Due to this, we are getting performance Issue and server is getting hanged. Can anyone help us providing the best way to search the attributes under an element if you have faced similar issue please?

 

Code Snippet

 

PIPointList pointList = new PIPointList();

AFNamedCollectionList<AFElement> ElementList = AFElement.FindElementsByCategory(Analytics_AFDatabase

, null

, afdf

, true

, AFSortField.Name

, AFSortOrder.Descending

, 0

, int.MaxValue

, out totalElements);

Log.Info("Total Elements found: " + totalElements); -> 350 Elements

 

// Build the Attribute information for all elements

Parallel.ForEach(ElementList, new ParallelOptions { MaxDegreeOfParallelism = 8 }, myelement =>

{

// Find all of the attributes for Exception Calculation

AFAttributeList myAttributes = AFAttribute.FindElementAttributes(Analytics_AFDatabase,

myelement,

"",

null,

null,

AFElementType.Any,

"",

afCalcCategory,

TypeCode.Empty,

true,

AFSortField.Name,

AFSortOrder.Descending,

3000);

 

// Create the structures and add them to the pointlist

pointList.AddRange(CreateInfoStructures(myelement, myAttributes ));

 

    myAttributes .Clear();

});

 

Thanks in advance.

Outcomes