-
Notifications
You must be signed in to change notification settings - Fork 14
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
create-ref
doesn't seem to clean up after element is destroyed
#56
Comments
Hi @swastik, thank you for report! |
We are on an older version (3.x.x). It seems like that's called when elements are inserted into the DOM: Screen.Recording.2023-10-05.at.11.08.28.movBut not when they are destroyed: Screen.Recording.2023-10-05.at.11.09.00.mov |
In the latest version (5.0.4), it seems like it is called the way you expect, however, we still end up with what seems like detached elements in memory at the end. I'm not sure if it's this addon causing it or something deeper down the stack? Screen.Recording.2023-10-05.at.11.15.52.mov |
@swastik I think we could try to create reproduction test with access to // component for test
{
constructor() {
this.args.sendContext(this);
}
} // test logic
let context = null;
this.onSetContext = (ctx) => {
context = ctx;
}
this.render('<Component @sendContext={{this.onSetContext}} />`)
// here we do some mutations
// here we check for `context.ref_1`, `context.ref_2`, etc to check is it alive or not |
So I think what's happening is this destructor: registerDestructor(this, () => {
this.cleanMutationObservers();
this.cleanResizeObservers();
getNodeDestructors(this._element).forEach((cb) => cb());
}); … is not clearing keys from the bucket. if I add a registerDestructor(this, () => {
this.cleanMutationObservers();
this.cleanResizeObservers();
bucketFor(this._ctx).delete(this._key)
getNodeDestructors(this._element).forEach((cb) => cb());
}); … and in delete(name) {
delete this.bucket[name];
delete this.keys[name];
}, That seems to remove references to the element etc. Does that make sense, or is it not intended to work like that? |
@lifeart thank you, I'll take a look this week. We shipped a patch with WeakRef with |
@lifeart I tried that out locally and it did work! |
HI @swastik! |
I have some code like above. When I add 100 items, then clear them, I'm expecting that those elements won't show up in memory, but I'm still seeing them as detached elements. Here's a screenshot from Edge:
The text was updated successfully, but these errors were encountered: