perf(memory): drop disposable caches on pressure

This commit is contained in:
zarzet
2026-07-16 10:32:33 +07:00
parent c75139450a
commit ef89352d09
9 changed files with 100 additions and 3 deletions
+1 -1
View File
@@ -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() {
+4 -2
View File
@@ -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 (_) {}
}