Skip to content

Optimize: Add bounded LRUCache for text measurement and wrapping with tests - #175

Open
dirwin31 wants to merge 2 commits into
firestar5683:Domfrom
dirwin31:LRUCache
Open

dirwin31 wants to merge 2 commits into
firestar5683:Domfrom
dirwin31:LRUCache

Conversation

@dirwin31

Copy link
Copy Markdown

Description:

system/ui/lib/text_measure.py and system/ui/lib/wrap_text.py memoize results in module-global dicts that are never evicted or size-capped:

Many call sites pass per-frame-varying text, including raw float formatting. Each distinct string produces a new key, so these caches grow without bound over a long UI session — a slow memory leak that doesn't recover until the process restarts.

Fix:
bound each cache with an LRU. Keys and lookup semantics are unchanged; only eviction is added.

Verification:
Added system/ui/lib/tests/test_text_caches.py
system/ui/lib/tests -66 passed
system/ui/lib/tests system/ui/tests - 73 passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant