Skip to content

fix: Prune cache at startup if needed, prevent crashes and OOMs#2139

Merged
nikclayton merged 1 commit intopachli:mainfrom
nikclayton:prune-cache-if-needed
Feb 24, 2026
Merged

fix: Prune cache at startup if needed, prevent crashes and OOMs#2139
nikclayton merged 1 commit intopachli:mainfrom
nikclayton:prune-cache-if-needed

Conversation

@nikclayton
Copy link
Copy Markdown
Contributor

Some devices don't run WorkManager tasks reliably. See details at https://dontkillmyapp.com/.

This is a problem, as if the local database gets too large the timeline queries can take seconds to run or return too much data, leading to poor performance, OOM crashes, or others.

Work around this for the moment by pruning the cache in IntentRouterActivity, the MAIN activity.

The cache is pruned if there are more 800 rows in TimelineStatusWithAccount, a figure-in-the-air guess at how many rows is likely to indicate that the workers aren't running as expected.

While I'm here, update the "Prune cache" feature in DatabaseFragmentViewModel to prune the log as well.

Some devices don't run WorkManager tasks reliably. See details at
https://dontkillmyapp.com/.

This is a problem, as if the local database gets too large the timeline
queries can take seconds to run or return too much data, leading to poor
performance, OOM crashes, or others.

Work around this for the moment by pruning the cache in `IntentRouterActivity`,
the `MAIN` activity.

The cache is pruned if there are more 800 rows in `TimelineStatusWithAccount`,
a figure-in-the-air guess at how many rows is likely to indicate that the
workers aren't running as expected.

While I'm here, update the "Prune cache" feature in `DatabaseFragmentViewModel`
to prune the log as well.
@nikclayton nikclayton merged commit 5c73cd2 into pachli:main Feb 24, 2026
27 checks passed
@nikclayton nikclayton deleted the prune-cache-if-needed branch February 24, 2026 12:36
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