-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Prevent memory leak of PerformanceObserver #24074
Comments
Performane
would result in leaking Window
after a pipeline was closedPerformance
would result in leaking Window
after a pipeline was closed
cc @asajeffrey @jdm I think it is plausible, and also that it's not what happened in this specific case, and that instead we're leaking
We could look into changing the structure of how observers are stored, so that they are only kept alive by their corresponding I need to look more into it. It could look something like: we could separate the Then the global could keep a strong ref to the Then the global could run a periodic checkpoint like is done for messageports at https://github.com/servo/servo/pull/23637/files#diff-59d233642d0ce6d687484bdd009e1017R484 |
On the other hand, I'm not actually sure the code at https://gist.github.com/kanaka/119f5ed9841e23e35d07e8944cca6aa7 creates any observers, which could invalidate the above logic(at least with regards to the leaking perceived when running that script). Will require looking into more closely. |
Ah ok, even if there are no observers set, we still often buffer the entry at servo/components/script/dom/performance.rs Line 244 in 39bd455
And this happens for instance each time script does a fetch:
used for example by the stylesheet loader(used in the debug script that was leaking docs): servo/components/script/stylesheet_loader.rs Line 233 in 799490a
Itself called by fetch at servo/components/net_traits/lib.rs Line 260 in 9bba14c
|
Ok so this #24109 fixes the actual cause of the leak, and removes the previous changes that set The cause of the perceived leak was indeed the buffer, as no performance observers were created. Leaving this one open, since I think we should still fix the issue with the performance observers, which leak unless script calls |
Performance
would result in leaking Window
after a pipeline was closed…asajeffrey Performance: limit buffer size, clear on pipeline exit <!-- Please describe your changes on the following line: --> Part of #24074 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24109) <!-- Reviewable:end -->
…<try> Performance: limit buffer size, clear on pipeline exit <!-- Please describe your changes on the following line: --> Part of #24074 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24109) <!-- Reviewable:end -->
…<try> Performance: limit buffer size, clear on pipeline exit <!-- Please describe your changes on the following line: --> Part of #24074 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24109) <!-- Reviewable:end -->
…asajeffrey Performance: limit buffer size, clear on pipeline exit <!-- Please describe your changes on the following line: --> Part of #24074 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24109) <!-- Reviewable:end -->
…asajeffrey Performance: limit buffer size, clear on pipeline exit <!-- Please describe your changes on the following line: --> Part of #24074 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24109) <!-- Reviewable:end -->
#24072 fixes the leak, but the underlying reason is still not clear.
It could be that if we didn't clear the performance list, then it ended up getting entries added to it but never removed, so if you quickly navigated away from the page it just sat there being a memory leak?
Originally posted by @asajeffrey in #24072 (comment)
See also other comments in that PR.
The text was updated successfully, but these errors were encountered: