I have a big problem with memory, i try many things but it’s doesn’t effect.
It’s my code for testing memory :
const { wasmContext, sciChartSurface } = await SciChartSurface.create("bandTest", { theme: new SciChartJSLightTheme() });
sciChartSurface.title = "Axis 1";
sciChartSurface.xAxes.add(new NumericAxis(wasmContext, { axisTitle: "Column number", axisTitleStyle: {fontSize: 12} }));
sciChartSurface.yAxes.add(new NumericAxis(wasmContext, { axisAlignment: EAxisAlignment.Left, axisTitleStyle: {fontSize: 12} }));
setTimeout(sciChartSurface.delete(),2000);
sciChartSurface.delete() have no effect for memory
I run snapshot without this code and another snapshot with this code. (snap 14 is before call SciChart and snap 15 is after call the code bellow)
What can I do?
Regards
- Marjorie lesage asked 9 months ago
- last edited 9 months ago
- You must login to post comments
Good morning Margorie,
SciChart.js v3.2 has been released this week, which fixes a memory leak in Webassembly and improves memory management throughout.
Some content which is particularly applicable to memory use includes:
- Memory Best Practices documentation
- Memory Leak Debugging
- Best practice tutorial – creating a re-usable React Component with delete / proper lifecycle
- Our new Getting-Started page also has some best-practice for component lifecycle to delete charts on unmount.
Best regards,
Andrew
- Andrew Burnett-Thompson answered 9 months ago
- last edited 8 months ago
- You must login to post comments
Hi Marjorie,
Memory is being released when you call SciChartSurface.delete() but back to WebAssembly not to the browser. Also, we are caching our graphics engine so the next Chart startup time is faster. If you instantiate a second chart and delete it memory won’t grow. It will stay the same.
You’re going to be really happy to know we’ve made a massive improvement to memory in v3.2 of SciChart.js which is in beta now.
You can try the beta from npm.
Try the code above in 3.2.0-beta but with this:
SciChartSurface.createSingle();
Instead of this
SciChartSurface.create();
And you will see as soon as the chart is deleted and garbage collected by javascript memory returns to the browser. Snapshot memory should go down.
There will also be a way in v3.2 to collect all memory using SciChartSurface.create() by setting some flags to destroy the WebGL buffers and engine.
We’ll be announcing more details on memory improvements very soon.
Best regards
Andrew
- Andrew Burnett-Thompson answered 9 months ago
- last edited 9 months ago
- You must login to post comments
Please login first to submit.