Skip to content

script: Correctly handle Reflector with AssociatedMemory and remove associated memory in finalize instead of drop#42271

Merged
jdm merged 2 commits intoservo:mainfrom
sagudev:f-asoc-mem
Feb 1, 2026
Merged

script: Correctly handle Reflector with AssociatedMemory and remove associated memory in finalize instead of drop#42271
jdm merged 2 commits intoservo:mainfrom
sagudev:f-asoc-mem

Conversation

@sagudev
Copy link
Copy Markdown
Member

@sagudev sagudev commented Feb 1, 2026

Reviewable per commits:

As noted in #42180 (comment) transmuting &Reflector<AssociatedMemory> to &Reflector<()> will ignore AssociatedMemory information and thus it will not remove extra associated memory. By returning &Reflector<Self::ReflectorType> from DomObject::reflector() we will preserve this information and thus correctly handle cases with associated memory. We also do not need overrideMemoryUsage in bindings.conf anymore. 🎉

Instead of removing associated memory in drop code we should do it as part of finalizers, otherwise we have problems in nested (inherited) structs, where drop is run for both parent and child, but we only added associated memory for child (on init_reflector) which already included size of parent. The only exception here is promise, because it is RCed and not finalized.

Testing: Tested locally that it fixes speedometer.
Fixes #42269

@sagudev sagudev requested a review from gterzian as a code owner February 1, 2026 07:29
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 1, 2026
@sagudev sagudev requested review from jdm and removed request for gterzian February 1, 2026 07:29
This only matters for nested/inherited structs, where we do not want for parent to do release.

Signed-off-by: sagudev <[email protected]>
@sagudev sagudev changed the title script: Improve handling of Reflector with AssociatedMemory script: Correctly handle Reflector with AssociatedMemory and free memory in finalize instead of drop Feb 1, 2026
@sagudev sagudev changed the title script: Correctly handle Reflector with AssociatedMemory and free memory in finalize instead of drop script: Correctly handle Reflector with AssociatedMemory and remove associated memory in finalize instead of drop Feb 1, 2026
Copy link
Copy Markdown
Member

@jdm jdm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Feb 1, 2026
@jdm jdm added this pull request to the merge queue Feb 1, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Feb 1, 2026
Merged via the queue into servo:main with commit 0f9f601 Feb 1, 2026
34 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Feb 1, 2026
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.

Linux Speedometer keeps timeout in CI since #42180

3 participants