Repository navigation
Prevent periodic database vacuuming on Android 17+ - #8319
Merged
jmartinesp merged 2 commits intoDec 2, 2026
Merged
Conversation
On Android, when we VACUUM a sqlite DB, this is loaded fully into RAM because of how the sqlite3 binary is built for the platform. On Android 17+, there are native memory limits too, which means an app using too much RAM even with outside the JVM can get silently killed by the OS. With large databases, like the event cache or the media ones once they grow for a long while, periodic vacuuming can mean loading GBs into RAM, and the app will crash.
Contributor
|
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8319 +/- ##
===========================================
- Coverage 81.13% 81.13% -0.01%
===========================================
Files 2906 2906
Lines 87614 87619 +5
Branches 11897 11898 +1
===========================================
Hits 71088 71088
- Misses 11889 11894 +5
Partials 4637 4637 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
On Android, when we VACUUM a sqlite DB, this is loaded fully into RAM because of how the sqlite3 binary is built for the platform. On Android 17+, there are native memory limits too, which means an app using too much RAM even with outside the JVM can get silently killed by the OS. With large databases, like the event cache or the media ones once they grow for a long while, periodic vacuuming can mean loading GBs into RAM, and the app will crash.
jmartinesp
force-pushed
the
fix/stop-periodic-database-vacuuming-on-android-17
branch
from
December 2, 2026 09:40
cee4b91 to
5440f00
Compare
bmarty
approved these changes
Dec 2, 2026
| "Skipping database vacuuming on Android 17+, as this can cause the app to be killed by the system due to excessive memory usage. " + | ||
| "See https://developer.android.com/about/versions/17/behavior-changes-17" | ||
| ) | ||
| return Result.success() |
Member
There was a problem hiding this comment.
Maybe also add (not replace) this test on scheduleDatabaseVacuum()
Member
Author
There was a problem hiding this comment.
I thought about doing that too, but this is a stopgap measure until we get a proper fix in the SDK, so I wanted to change as little code as possible since we'll revert it later.
jmartinesp
deleted the
fix/stop-periodic-database-vacuuming-on-android-17
branch
December 2, 2026 10:33
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.
Content
What the title says.
Motivation and context
On Android, when we VACUUM a sqlite DB, this is loaded fully into RAM because of how the sqlite3 binary is built for the platform.
On Android 17+, there are native memory limits too, which means an app using too much RAM even with outside the JVM can get silently killed by the OS.
With large databases, like the event cache or the media ones once they grow for a long while, periodic vacuuming can mean loading GBs into RAM, and the app will crash.
There is also matrix-org/matrix-rust-sdk#7585 to disable these operations in the SDK when rooms or medias are removed from the databases. We should use incremental vacuuming instead, but that's way more complex and needs thorough testing.
Tests
Not easy to test: you'd have to use an emulator or real device in Android 17, then have a DB which has grown quite large and allow the vacuum worker to run. Previously, this should have caused a crash, now you should see the new 'Skipping database vacuuming on Android 17+' warning log, and the DBs won't be vacuumed.
Vacuuming the DBs from the developer options screen should still cause the crash, if that happened before.
Checklist
/code-reviewrun in a fresh session) before requesting a human review.