SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

Answered
0
0

In my application I remove lines from SciChartSurface, but Resharper still shows that data not removed from memory.
How completely remove from memory, that GC would collect it?

Edited:

I found smth strange, don’t even know if it’s my issue or not.
The structure shows what keeps my data alive.

using (sciChart.SuspendUpdates())
                {
                    for (var i = 0; i < pavadinimai.Count; i++)
                    {
                        if (pavadinimai[i] != null)
                        {
                            this.Dispatcher.Invoke((Action)(() =>
                            {
                                var sarasas = new List<Duomenys>(LinijuSarasas);
                                var line = sarasas.SingleOrDefault(p => p.Linija.Name == pavadinimai[i]);
                                try
                                {
                                        string pavadin = pavadinimai[i];
                                        var Ynauj = Ynauji[i].Select(p => (double)p).ToList();
                                        line.XyAsiesTaskai.Append(Xnauji, Ynauj);
                                }
                                catch (Exception e)
                                {
                                    MessageBox.Show(e.ToString());
                                }
                            }));
                        }
                    }
                }

And

var asis = asiesNr.ToString();
            using (sciChart.SuspendUpdates())
            {
                for (var i = 0; i < YdtSeries.Count; i++)
                {
                    if (pavadinimai[i] != null)
                    {
                        var dataSeries = MasyvasIXySeries(XdtSeries, YdtSeries[i], pavadinimai[i]);
                        var rnd = new Random().Next(0, 10);
                        var Fast = new FastLineRenderableSeries() { SeriesColor = spalvuMasyvas[i], DataSeries = dataSeries, Name = pavadinimai[i], YAxisId = asis, StrokeThickness = 1 };
                        PridetiLinijaPrieSaraso(dataSeries, asiesNr, asis, Fast, true, false);
                        sciChart.RenderableSeries.Add(Fast);
                        //sciChart.ZoomExtents();
                    }
                }
            }
  • You must to post comments
Best Answer
1
0

From the information you’ve given me so far,

if you call SciChartSurface.SuspendUpdates() it will return a token which holds a reference to the SciChartSurface. You must call .Dispose() on that token or the SciChartSurface will never be released from memory.

e.g.

var token = SciChartSurface.SuspendUpdates();
// ... 
token.Dispose();

or

using (SciChartSurface.SuspendUpdates())
{
    // ... 
}

if you are already doing this throughout your code, there is one more place where this type of memory leak could occur. If your SciChartSurface is never loaded in the visual tree, it can hold memory internally. To work around this, simply force OnLoad()

// Forces initialization. Also removes an ISuspendable used internally to SciChart
sciChartSurface.OnLoad()

Let me know if this helps.

Best regards,
Andrew

  • Elteros Projektai
    No, It didn't. I even tried to disable all .SuspendUpdates(), but it didn't change nothing.
  • Andrew
    If you can email us a code sample we will investigate. We have no other reports of memory leaks related to ISuspendable that we know of.
  • Elteros Projektai
    I put OnLoad() at the inicialization and it started to work. I found out that ISuspendable holds chart even without data. Thank you very much for fast support.
  • Andrew
    This suggests to me you have a chart which is never shown on screen (SciChartSurface.Loaded never fires). Just be sure this is intentional! Best regards, Andrew
  • butcher90
    Great answer! My code created SciChartSurface was not released and produced a memory leak. After calling OnLoad() the issue seems to be fixed!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.