Optimize package icon loading and memory management#5069
Merged
Gabriel Dufresne (GabrielDuf) merged 8 commits intoJul 10, 2026
Conversation
Marc-André Moreau (mamoreau-devolutions)
approved these changes
Jul 10, 2026
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.
This pull request introduces significant improvements to memory usage and icon loading efficiency in the application. The changes implement a memory trimming mechanism for Windows, overhaul the package icon loading and caching system to be more performant and memory-friendly, and add logic to only load icons for visible rows. Additionally, icons are now downscaled to reduce memory usage, and the icon cache can be reset more reliably. The most important changes are grouped below:
Memory Management Improvements:
MemoryTrimmerutility for Windows that returns unused memory to the OS after UI loads settle, reducing the app's working set. This is triggered after loading completes and can be canceled if a new load starts (MemoryTrimmer.cs,MainWindowViewModel.cs,UniGetUI.Avalonia.csproj).UniGetUI.Avalonia.csproj).Icon Loading and Caching Overhaul:
Replaced the old concurrent dictionary icon cache with a custom LRU cache, capped at 512 entries, to reduce memory pressure and avoid rooting unused bitmaps. The cache can now be cleared programmatically (
PackageCollections.cs).Increased icon loading concurrency and added per-row cancellation tokens to ensure that icon loads for discarded rows are canceled, preventing memory leaks (
PackageCollections.cs).Icons are now loaded lazily only when their row becomes visible, rather than preloading for all results. This is coordinated via a new
PackageIconLoaderattached property and corresponding XAML changes (PackageIconLoader.cs,AbstractPackagesPage.axaml).Icon Decoding and Memory Usage:
Added logic to downscale oversized icons to a maximum of 128x128 pixels before caching, reducing memory usage for large icon files (
PackageCollections.cs).Improved error handling and cancellation support during icon decoding and loading, making the UI more responsive and robust (
PackageCollections.cs).Other Improvements:
WinGetCliHelper.cs).These changes collectively result in a more responsive UI, lower memory footprint, and improved user experience, especially when browsing large package lists or running the app for extended periods.