mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-17 23:32:19 +02:00
fix(memory): release retired runtimes and idle download heap
This commit is contained in:
@@ -1395,6 +1395,7 @@ class DownloadService : Service() {
|
||||
failed = counts.failed,
|
||||
)
|
||||
currentStatus = "finalizing"
|
||||
releaseIdleDownloadMemory()
|
||||
writeNativeWorkerSnapshot(
|
||||
isRunning = false,
|
||||
isPaused = false,
|
||||
@@ -1702,6 +1703,7 @@ class DownloadService : Service() {
|
||||
failed = counts.failed,
|
||||
)
|
||||
currentStatus = "finalizing"
|
||||
releaseIdleDownloadMemory()
|
||||
writeNativeWorkerSnapshot(
|
||||
isRunning = false,
|
||||
isPaused = false,
|
||||
@@ -1718,6 +1720,16 @@ class DownloadService : Service() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun releaseIdleDownloadMemory() {
|
||||
try {
|
||||
// All workers and album tagging have finished. Return unused Go
|
||||
// heap without forcing a collection between individual tracks.
|
||||
Gobackend.releaseMemory()
|
||||
} catch (e: Exception) {
|
||||
android.util.Log.w("SpotiFLAC", "Failed to release idle download memory: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun ensureWakeLock() {
|
||||
val existingWakeLock = wakeLock
|
||||
|
||||
Reference in New Issue
Block a user