-
Notifications
You must be signed in to change notification settings - Fork 6k
Reclaim paragraph memory more aggressively #26438
Conversation
harryterkelsen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach seems good to me
| /// blowing up if within a single frame the framework needs to layout a lot of | ||
| /// paragraphs. One common use-case is `ListView.builder`, which needs to layout | ||
| /// more of its content than it actually renders to compute the scroll position. | ||
| void release() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this name is a little confusing. release makes me think we are telling the cache to delete this paragraph ASAP. I think something like addToCache or markUsed would make more sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Done.
harryterkelsen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* delete paragraphs between layout and render
Put
CkParagraphobjects into a separate synchronous cache, which reclaims memory synchronously. This significantly reduces paragraph memory usage for very longListViews and other cases where lots of paragraphs are laid out but not rendered. It does not fully cover the use-case where we both lay out and render tons of paragraphs (it fixes the memory issue but not the performance issue). For that we need flutter/flutter#81224.Some benchmark numbers:
text_canvas_kit_color_grid: before 420MB, after 153MBLayout and render 10000 paragraphs: before 1GB, after 200MB
sample 1, 60 seconds (by @slavap): before 600MB, after 168MB
sample 2, 100 tab switches (by @asjqkkkk): before 422MB, after 253MB
Fixes flutter/flutter#66614