getSystemMemoryInMegabytes method

  1. @visibleForTesting
int getSystemMemoryInMegabytes()

Implementation

@visibleForTesting
int getSystemMemoryInMegabytes() {
  final memory = calloc<Uint64>();
  try {
    final result = GetPhysicallyInstalledSystemMemory(memory);
    if (result != 0) {
      return memory.value ~/ 1024;
    } else {
      final error = GetLastError();
      throw WindowsException(HRESULT_FROM_WIN32(error));
    }
  } finally {
    calloc.free(memory);
  }
}