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
+8
View File
@@ -1202,6 +1202,14 @@ class PlatformBridge {
await _channel.invokeMethod('clearLogs');
}
/// 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 {
try {
await _channel.invokeMethod('releaseMemory');
} catch (_) {}
}
static Future<int> getGoLogCount() async {
final result = await _channel.invokeMethod('getLogCount');
return result as int;