Pre loader

Best way to destroy a chart

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1
0

Hi –

I could not find an example in the various examples your provide

I have several charts in different components

When a component is closed I want to ensure the chart is destroyed and there is not potential for memory leak

What is this best way of doing this?

Thanks

Version
"scichart": "^3.2.0-beta",
  • You must to post comments
0
0

Hi Himura

We have a blog post on this recently published: Debugging JavaScript and WebAssembly Memory Leaks using the SciChart.js debug tools

And this links to our documentation pages on Memory Best Practices.

In short, to delete a chart:

  1. once you are finished with a chart, call sciChartSurface.delete();
  2. delete or remove the <div/> which the SciChartSurface was hosted in
  3. ensure all references to sciChartSurface and its wasmContext are detached (aka don’t keep them in global variables)

This will ensure proper cleanup of memory.

Depending on what framework you’re using: React, Angular, Vue or vanilla JS, there may be different ways to achieve this in practice.

For React we have a guide here on creating a Reusable React Component which automatically cleans up memory. We are also in the process of publishing an open source scichart-react npm package which will do all this for you. Other frameworks (Vue, Angular) may follow depending on user demand.

Let me know if this helps!

Best regards
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.