-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Memory leaks when using newInstance
to create multiple hljs instances
#4086
Comments
newInstance
newInstance
to create multiple hljs instances
I can see the issue here, though |
How would anyone suggest we fix this, track some global state on |
I don't think a standalone hljs instance should have global side effects. Perhaps an additional configuration option would be better, but I'm not sure if this would break highlight.js and it might increase the bundle size. It seems like that the operations on the |
What if this code was moved inside the conditional portion of |
Seems like a good idea |
@immccn123 is there any new version for this fix? |
@joshgoebel @immccn123 Also curious about this, saw the updated CHANGES.md for 11.11.0 but no associated publish to npm yet. |
Will try to get a few more of the open PRs resolved and then do a release after that. Wanting the next 11 release to be the last and then switch over to v12 betas. |
Describe the issue/behavior that seems buggy
Calling
newInstance
multiple times poses a risk of memory leaks.Sample Code or Instructions to Reproduce
see remarkjs/react-markdown#791 (comment)
Expected behavior
newInstance
should not callwindow.addEventListener('DOMContentLoaded', boot, false)
.Additional context
In function HLJS:
highlight.js/src/highlight.js
Lines 838 to 840 in e1fa2ea
Related:
remarkjs/react-markdown#791 rehypejs/rehype-highlight#31
The text was updated successfully, but these errors were encountered: