mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb: Make Agent's MutationObserver list weak
Before this change, Agent held on to all of the live MutationObserver objects via GC::Root. This prevented them from ever getting garbage-collected. Instead of roots, we now use a simple IntrusiveList and remove them from it in the finalizer for MutationObserver. This fixes a massive GC leak on Speedometer.
This commit is contained in:
parent
f1801fb1d2
commit
53c9c6f3ee
Notes:
github-actions[bot]
2025-02-07 15:54:21 +00:00
Author: https://github.com/awesomekling
Commit: 53c9c6f3ee
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3488
Reviewed-by: https://github.com/shannonbooth
4 changed files with 14 additions and 6 deletions
|
@ -35,9 +35,11 @@ MutationObserver::MutationObserver(JS::Realm& realm, GC::Ptr<WebIDL::CallbackTyp
|
|||
|
||||
MutationObserver::~MutationObserver()
|
||||
{
|
||||
HTML::relevant_agent(*this).mutation_observers.remove_all_matching([this](auto& observer) {
|
||||
return observer.ptr() == this;
|
||||
});
|
||||
}
|
||||
|
||||
void MutationObserver::finalize()
|
||||
{
|
||||
HTML::relevant_agent(*this).mutation_observers.remove(*this);
|
||||
}
|
||||
|
||||
void MutationObserver::initialize(JS::Realm& realm)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue