🐛 fix Coil memory cache limit being overridden to 435 MiB - #4912
Merged
Conversation
The Coil MemoryCache builder called maxSizeBytes(256 MiB) and then maxSizePercent(0.85), and the second call replaces the first. On non-Android targets Coil hard-codes the "total memory" at 512 MiB, so the strong-reference LRU was actually 435 MiB and filled up over days of use, which is most of the growth reported in #4908. Drop the overriding call so the intended 256 MiB limit applies.
guiyanakuang
force-pushed
the
zap/idle-memory-footprint
branch
from
September 3, 2026 04:03
eb19cfa to
1307758
Compare
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.
Summary
Part of #4908 (903 MB physical footprint after ~6 days idle). Independent of #4911, which handles the thread count side.
DesktopAppModulebuilt the shared CoilMemoryCachewith.maxSizeBytes(256 MiB)followed by.maxSizePercent(context, 0.85). In Coil 3 the second call replaces the first (maxSizeBytesFactoryis a single field), and on non-Android targetstotalAvailableMemoryBytes()is hard-coded to 512 MiB, so the strong-reference LRU was actually 435 MiB. It fills slowly with every thumbnail and preview the user scrolls past, which matches the "grows with uptime, then plateaus" shape in the report. The overriding call is removed so the intended 256 MiB limit applies.GC tuning flags were part of the first revision of this PR and have been dropped:
-XX:ParallelGCThreadsis a fixed count rather than a cap and-XX:+UseG1GCwould force G1 onto single-core machines that default to Serial, and the remaining periodic-GC / heap-free-ratio flags need real-machine RSS, pause and CPU measurements before they are worth shipping. They will come back as a separate PR once that A/B exists.Test plan
app:compileKotlinDesktop