On each new bar, I create a new class, which also creates and manage SortedList, and assign it to the series.
To keep my memory managed well, do I need to clear or release memory occupied by these classes on OnStateChange State=Terminated, or when the chart refresh?
To clear, here is an example of my series and my class:
private Series<TPObar> TPOseries;
TPOseries = new Series<TPObar>(this);
public class TPObar {
public SortedList<double, TPObarPrice> TPObarPrices;
public TPObar()
{
TPObarPrices = new SortedList<double, TPObarPrice>();
}
public void Clear()
{
if (TPObarPrices != null)
{
TPObarPrices.Clear();
}
}
}
protected override void OnBarUpdate()
{
...
...
TPObar CurrTPObar;
CurrTPObar = TPOseries[0];
if (CurrTPObar == null)
{
// New bar, create the TPObar
CurrTPObar = new TPObar();
}
...
my logic
...
TPOseries[0] = CurrTPObar;
...
}

Comment