all: fix db memory leak
Fix an issue where the database instances would leak memory due to an incorrect context use.
This commit is contained in:
parent
2413edfd5e
commit
4012c35cf4
3 changed files with 6 additions and 2 deletions
|
@ -187,7 +187,9 @@ private abstract class CacheDatabase : RoomDatabase() {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
val newInstance =
|
val newInstance =
|
||||||
Room.databaseBuilder(
|
Room.databaseBuilder(
|
||||||
context, CacheDatabase::class.java, "auxio_metadata_cache.db")
|
context.applicationContext,
|
||||||
|
CacheDatabase::class.java,
|
||||||
|
"auxio_metadata_cache.db")
|
||||||
.fallbackToDestructiveMigration()
|
.fallbackToDestructiveMigration()
|
||||||
.fallbackToDestructiveMigrationFrom(0)
|
.fallbackToDestructiveMigrationFrom(0)
|
||||||
.fallbackToDestructiveMigrationOnDowngrade()
|
.fallbackToDestructiveMigrationOnDowngrade()
|
||||||
|
|
|
@ -69,7 +69,7 @@ abstract class PersistenceDatabase : RoomDatabase() {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
val newInstance =
|
val newInstance =
|
||||||
Room.databaseBuilder(
|
Room.databaseBuilder(
|
||||||
context,
|
context.applicationContext,
|
||||||
PersistenceDatabase::class.java,
|
PersistenceDatabase::class.java,
|
||||||
"auxio_playback_persistence.db")
|
"auxio_playback_persistence.db")
|
||||||
.fallbackToDestructiveMigration()
|
.fallbackToDestructiveMigration()
|
||||||
|
|
|
@ -280,6 +280,7 @@ interface PlaybackStateManager {
|
||||||
*/
|
*/
|
||||||
fun get(): PlaybackStateManager {
|
fun get(): PlaybackStateManager {
|
||||||
val currentInstance = INSTANCE
|
val currentInstance = INSTANCE
|
||||||
|
logD(currentInstance)
|
||||||
|
|
||||||
if (currentInstance != null) {
|
if (currentInstance != null) {
|
||||||
return currentInstance
|
return currentInstance
|
||||||
|
@ -553,6 +554,7 @@ private class RealPlaybackStateManager : PlaybackStateManager {
|
||||||
// Internal player may have reloaded the media item, re-seek to the previous position
|
// Internal player may have reloaded the media item, re-seek to the previous position
|
||||||
seekTo(savedState.positionMs)
|
seekTo(savedState.positionMs)
|
||||||
}
|
}
|
||||||
|
isInitialized = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- CALLBACKS ---
|
// --- CALLBACKS ---
|
||||||
|
|
Loading…
Reference in a new issue