update method

Future<void> update()

Query current memory usage and cache the result.

Implementation

Future<void> update() async {
  try {
    final result = await _channel.invokeMethod<double>('getMemoryUsage');
    if (result != null && result > 0) {
      _memoryUsageMb = result;
      return;
    }
  } on MissingPluginException {
    // No native handler — fall through to dart:io.
  } on PlatformException {
    // Native error — fall through to dart:io.
  }

  // Fallback: resident set size from dart:io.
  final rss = ProcessInfo.currentRss;
  _memoryUsageMb = rss / (1024 * 1024);
}