41 PROCESS_MEMORY_COUNTERS info;
42 GetProcessMemoryInfo(GetCurrentProcess(), &info,
sizeof(info));
43 return (
size_t)info.PeakWorkingSetSize;
45#elif (defined(_AIX) || defined(__TOS__AIX__)) || (defined(__sun__) || defined(__sun) || defined(sun) && (defined(__SVR4) || defined(__svr4__)))
49 if ((fd = open(
"/proc/self/psinfo", O_RDONLY)) == -1)
51 if (read(fd, &psinfo,
sizeof(psinfo)) !=
sizeof(psinfo))
57 return (
size_t)(psinfo.pr_rssize * 1024L);
59#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
62 getrusage(RUSAGE_SELF, &rusage);
63#if defined(__APPLE__) && defined(__MACH__)
64 return (
size_t)rusage.ru_maxrss;
66 return (
size_t)(rusage.ru_maxrss * 1024L);
83 PROCESS_MEMORY_COUNTERS info;
84 GetProcessMemoryInfo(GetCurrentProcess(), &info,
sizeof(info));
85 return (
size_t)info.WorkingSetSize;
87#elif defined(__APPLE__) && defined(__MACH__)
89 struct mach_task_basic_info info;
90 mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
91 if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO,
92 (task_info_t)&info, &infoCount)
95 return (
size_t)info.resident_size;
97#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
101 if ((fp = fopen(
"/proc/self/statm",
"r")) == NULL)
103 if (fscanf(fp,
"%*s%ld", &rss) != 1)
109 return (
size_t)rss * (size_t)sysconf(_SC_PAGESIZE);