-
-
Notifications
You must be signed in to change notification settings - Fork 9k
Closed
Labels
❗ p4-importantPriority 4: this fixes bugs that violate documented behavior, or significantly improves perf.Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf.scope: reactivity
Description
Vue version
3.5.6
Link to minimal reproduction
Steps to reproduce
- Click the
Newbutton a few times. - Take a Heap Snapshot.
- Filter on the class
VTrack.
What is expected?
There should be only one instance of VTrack.
What is actually happening?
There is one instance per button click.
System Info
No response
Any additional comments?
- You can also filter for the
Depclass, as instances of that also leak. - This is reproducible from 3.5.0 to 3.5.6.
- It is not reproducible in 3.4, but it is reproducible in 3.3. I believe it is essentially the same underlying problem as fix(reactivity): fix dep memory leak #7827, which was fixed in 3.4.
- I've also tested in a Vite project with a production build. Testing in production is a little trickier as the classes are renamed, but they can be identified via a snapshot comparison.
The Set isn't required to reproduce the problem, it just makes it much easier to see. This example uses a normal object:
In this case there is no VTrack, so you need to filter for Dep to see the problem. A new Dep gets created for each button click, but they never get tidied up. The Set case is much worse as set.has(key) also leaks key, which could potentially be a large object.
Metadata
Metadata
Assignees
Labels
❗ p4-importantPriority 4: this fixes bugs that violate documented behavior, or significantly improves perf.Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf.scope: reactivity