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();
}
}
}
- Elteros Projektai asked 10 years ago
- last edited 10 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 10 years ago
- No, It didn't. I even tried to disable all .SuspendUpdates(), but it didn't change nothing.
- 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.
- 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.
- 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
- 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 login to post comments
Please login first to submit.