Repository navigation
fix: Release no longer visible items from memory - #22185
Conversation
Test Results1 247 files + 1 1 247 suites +1 1h 15m 55s ⏱️ +51s Results for commit 130fd8b. ± Comparison against base commit 0d6d1d0. This pull request removes 3 and adds 7 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
| dataGenerator.destroyData(item); | ||
| getKeyMapper().remove(item); |
There was a problem hiding this comment.
The call order is important. ComponentRenderer assumes that the item key is still present when destroyData is called. If the key is missing, the component won't be detached from the DOM and will cause memory to build up on the client side.
| // Clear items that are no longer visible from the cache to free memory. | ||
| // This also removes them from keyMapper and disposes of their data | ||
| // generated by dataGenerator. | ||
| rootCache.removeDescendantItemIf((item) -> getKeyMapper().has(item) |
There was a problem hiding this comment.
Checking getKeyMapper().has(item) makes sure to only remove items that were actually rendered, leaving any other cached items untouched.
|
| } | ||
|
|
||
| @Test | ||
| public void collapseItems_collapsedChildrenRemovedFromKeyMapper() { |
There was a problem hiding this comment.
note: this test was moved to HierarchicalDataCommunicatorKeyGenerationTest.
| } | ||
|
|
||
| @Test | ||
| public void collapseItems_dataGeneratorDestroyDataCalledForCollapsedChildren() { |
There was a problem hiding this comment.
note: this test was moved to the new HierarchicalDataCommunicatorDataGenerationTest.
This change ensures that items are removed from the HierarchicalDataCommunicator's cache and properly disposed of in both KeyMapper and DataGenerator once they move out of the viewport. Without this, such features as ComponentRenderer can cause high memory usage on the client side because the Flow client continues to retain references to DOM elements that are no longer visible. Related-to: #21876



Description
The PR ensures that items are removed from the HierarchicalDataCommunicator's cache and properly disposed of in both KeyMapper and DataGenerator once they move out of the viewport. Without this, such features as ComponentRenderer can cause high memory usage on the client side because the Flow client continues to retain references to DOM elements that are no longer visible.
Regression from #21876
Type of change