mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-29 07:18:49 +02:00
perf(memory): drop disposable caches on pressure
This commit is contained in:
+1
-1
@@ -229,7 +229,7 @@ class _EagerInitializationState extends ConsumerState<_EagerInitialization>
|
||||
if (CoverCacheManager.isInitialized) {
|
||||
CoverCacheManager.instance.store.emptyMemoryCache();
|
||||
}
|
||||
unawaited(PlatformBridge.releaseNativeMemory());
|
||||
unawaited(PlatformBridge.releaseNativeMemory(underPressure: true));
|
||||
}
|
||||
|
||||
void _initializeDeferredProviders() {
|
||||
|
||||
@@ -1168,9 +1168,11 @@ class PlatformBridge {
|
||||
|
||||
/// Ask the Go backend to GC and return freed heap to the OS. Best-effort:
|
||||
/// safe to call on memory pressure or when the app is backgrounded.
|
||||
static Future<void> releaseNativeMemory() async {
|
||||
static Future<void> releaseNativeMemory({bool underPressure = false}) async {
|
||||
try {
|
||||
await _channel.invokeMethod('releaseMemory');
|
||||
await _channel.invokeMethod(
|
||||
underPressure ? 'releaseMemoryUnderPressure' : 'releaseMemory',
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user