Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leaks #43

Merged
merged 2 commits into from
Jan 10, 2018
Merged

Fix memory leaks #43

merged 2 commits into from
Jan 10, 2018

Conversation

moberemk
Copy link
Contributor

@moberemk moberemk commented Jan 8, 2018

When using this library on our server we started running in to memory leaks past a certain scale; I believe I've identified the issues causing this memory leak and have a patch here to fix them, see commit comments for full details on the changes made and the rationale.

Should close #30

Promisifying this element causes a memory leak where every time a chart is created a number of evaled source code strings are held in memory and never released.
Calling the `destroy()` function is necessary to prevent a memory leak as otherwise the chart.js core code maintains references to every chart ever generated with this library. The `instances` variable it assigns references to, seen [here](https://github.com/chartjs/Chart.js/blob/master/src/core/core.controller.js#L105), is only ever cleared upon calling of the `destroy` function. It's not attached to any part of the DOM and therefore is not cleaned up by the destruction of the virtual DOM; it's a package-level variable that persists across all runs of the chart.js library.
@sedouard
Copy link
Contributor

@moberemk seems OK to me. thanks for the PR!

@sedouard sedouard merged commit 0e3ae87 into vmpowerio:master Jan 10, 2018
@moberemk
Copy link
Contributor Author

Glad I could help, hope you can put it out to NPM soon!

@sedouard
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memory leak while generating a lot of server side graphs
2 participants