physFootprint function

int physFootprint()

The process's physical footprint in bytes (what iOS holds against an app's memory limit); on Windows, its working set; on Linux and Android, its resident set size from /proc; -1 where none is available.

Implementation

int physFootprint() {
  final footprint = _physFootprint();
  if (footprint >= 0 || !(Platform.isAndroid || Platform.isLinux)) {
    return footprint;
  }
  try {
    final status = File('/proc/self/status').readAsStringSync();
    final kb = RegExp(r'VmRSS:\s*(\d+)').firstMatch(status)?[1];
    return kb == null ? -1 : int.parse(kb) * 1024;
  } on FileSystemException {
    return -1;
  }
}