Memory Leak in Preview Component #3822
Comments
@jvilk that looks like a great fix. Would you like to open the PR? Perhaps one tweak would be to reference the underlying source documents like we do here Stop by and say hello in our slack I'd love to chat source maps & debuggers with you some time. |
Are you involved in the source map visualization project? We're working on a product doc for some extra source map features. I'm curious to see what you think. |
I'm not directly involved, but I remember contributing ideas and maybe some code to that project. I do perform a lot of work with program transformations and source maps. I'll drop by the Slack channel to chat further. |
/claim |
Thanks for claiming the issue! 👋 Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to 🦊 Debugger team! |
Closing as the related PR got merged. |
The
Preview
component adds four event listeners to CodeMirror that remain after it unmounts.This leak adds around 500KB to
debugger.html
's heap size every time a source document is opened and closed.Forgive me for using a competing browser for capturing the heap; it's the setup I'm currently working with!
Experiment Setup
yarn start
Methodology
Perform the following tasks with an unmodified version of debugger.html, and a version of debugger.html with the leaks fixed:
http://localhost:8000/?firefox-tab=child1/tab1
main.js
to open it in the source viewer.x
to closemain.js
.Result
As you can see in the image below, debugger.html adds about 500KB to its heap every time
main.js
is opened and closed. After this leak is fixed,debugger.html
grows normally (the remaining heap growth, which stabilizes after a few iterations, is likely Chrome's JIT compiler in action).Suggested Actions
Save a reference to the used event handlers on the
Preview
object, and add acomponentWillUnmount
function that cleans up the handlers.The text was updated successfully, but these errors were encountered: