Repository navigation
Conversation
ValidationBindingTrackerViewPlugin maps each resolved node to its source node so it can carry binding trees from one update to the next. It cleared every other per-update map at the end of each root update, but never resolvedNodeMap, so the map kept every node any update had resolved, with its resolved subtree, for as long as the view was current. Clear the map with the others. It's only read while the root finishes an update, and every node in that update sets its entry first.
Contributor
Author
|
Replaced by #966, opened from a branch in this repository so the three PRs can be stacked. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ValidationBindingTrackerViewPluginkeeps every node that any update of a view resolves, for as long as the view stays current. A view whose data changes often grows memory with each update, and gets it back only when Player moves to another view.Why it's needed
The tracker maps each resolved node to its source node in
resolvedNodeMap, so it can carry validation bindings from one update to the next. When the root node finishes an update, it clears its other per-update maps, but notresolvedNodeMap. Each entry holds a resolved node and, through its children, that node's whole resolved subtree. So every update adds the nodes it resolved again, and the ones they replaced are never released.Any view that updates repeatedly while it stays on screen is affected: typing into inputs, polling, or data a plugin loads in the background. In a measurement with a view of 200 text assets updated 200 times, the heap grew by 14.24 MB on
mainand by 0.30 MB with this change.Change
Clear
resolvedNodeMapwith the other maps when the root finishes an update. The map is read only at that moment, and every node resolved in an update sets its entry before the root finishes, so nothing reads an entry this clears.Tests
binding-tracker.test.tsupdates a view 20 times, holds the nodes each update resolved inWeakRefs, forces garbage collection, and checks that the nodes later updates replaced were released. Onmain, 19 replaced nodes are still held after garbage collection; with the change, none are. The test turns ongcwithv8.setFlagsFromString("--expose-gc"), because vitest doesn't pass Node flags through to tests.Change Type (required)
Indicate the type of change your pull request is:
patchminormajorN/ADoes your PR have any documentation updates?