perf(memory): release Go heap and decoded image caches on OS memory pressure

This commit is contained in:
zarzet
2026-07-14 09:09:42 +07:00
parent f983a303fd
commit 96eb412fe5
4 changed files with 41 additions and 0 deletions
+10
View File
@@ -2,9 +2,19 @@ package gobackend
import (
"encoding/json"
"runtime/debug"
"strings"
)
// ReleaseMemory drops idle pooled extension runtimes, forces a GC, and
// returns freed heap to the OS. Called from the app on OS memory pressure and
// when backgrounded, so the Go side's RSS doesn't sit at its high-water mark
// after large downloads/tag writes.
func ReleaseMemory() {
drainAllIsolatedRuntimePools()
debug.FreeOSMemory()
}
func CheckAvailability(spotifyID, isrc string) (string, error) {
client := NewSongLinkClient()
availability, err := client.CheckTrackAvailability(spotifyID, isrc)