question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Room SQLiteConnectionPool leakage

See original GitHub issue

Room doesn’t close connection pool. After some background requests the logcat print the following warning message:

W/SQLiteConnectionPool: A SQLiteConnection object for database '%DATABASE_NAME%' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.

Current Room version:

implementation 'android.arch.persistence.room:runtime:1.1.1-rc1' annotationProcessor "android.arch.persistence.room:compiler:1.1.1-rc1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
svenjacobscommented, Oct 17, 2019

@svenjacobs I have used dependency injection, still getting the same issue.

If you use DI, make sure that the RoomDatabase instance is a singleton which is bound to the application lifecycle.

1reaction
svenjacobscommented, Aug 16, 2018

As it turns out the RoomDatabase instance must/should not be closed manually. The solution is to keep only one instance of the database in your application, for example in a static field in your Application class or managed via a dependency injection framework.

The leak warning will only occur if you open multiple database instances (for example one instance in each Activity) and don’t close them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQLite connection object leaked - Android - Stack Overflow
So my databaseHelper does extend SQLiteOpenHelper. I get a sqlite connection leak warning in the Logcat so would like some advice about what...
Read more >
refs/heads/androidx-room-release - Google Git
refs/heads/androidx-room-release. commit, 3da604b8524188eb6965fc43d22d6b4bfd7bd6b3 ... android/database/sqlite/SQLiteConnectionPool.java[Added - diff] ...
Read more >
Room/Paging: Needs a Way To Safely Close the Database ...
java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed. at android.database.sqlite.SQLiteConnectionPool.
Read more >
[Fixed]-Android Migrate from SQLite to Room
SQLiteConnectionPool : A SQLiteConnection object for database '/data/user/0/com. · SQLite GROUP BY on result of union not using indexes of constituent tables ...
Read more >
SQLite Android Bindings: Check-in Differences
To avoid memory leaks, the application should invoke [sqlite3_free()] ** on ... The underlying VFS might choose to preallocate database ** file space...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found