2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
10 #if defined(SK_BUILD_FOR_UNIX) || \
11 defined(SK_BUILD_FOR_MAC) || \
12 defined(SK_BUILD_FOR_ANDROID)
14 #include <sys/resource.h>
15 int sk_tools::getMaxResidentSetSizeMB() {
17 getrusage(RUSAGE_SELF, &ru);
18 #if defined(SK_BUILD_FOR_MAC)
19 return static_cast<int>(ru.ru_maxrss / 1024 / 1024); // Darwin reports bytes.
21 return static_cast<int>(ru.ru_maxrss / 1024); // Linux reports kilobytes.
25 #elif defined(SK_BUILD_FOR_WIN32)
28 int sk_tools::getMaxResidentSetSizeMB() {
29 PROCESS_MEMORY_COUNTERS info;
30 GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info));
31 return static_cast<int>(info.PeakWorkingSetSize / 1024 / 1024); // Windows reports bytes.
35 int sk_tools::getMaxResidentSetSizeMB() {