diff options
-rw-r--r-- | util/usage.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/util/usage.cc b/util/usage.cc index 23288b7..097c8ee 100644 --- a/util/usage.cc +++ b/util/usage.cc @@ -43,6 +43,7 @@ typedef WINBOOL (WINAPI *PFN_MS_EX) (lMEMORYSTATUSEX*); #include <sys/sysctl.h> #include <mach/task.h> #include <mach/mach.h> +#include <libproc.h> #endif namespace util { @@ -196,6 +197,18 @@ uint64_t RSSMax() { void PrintUsage(std::ostream &out) { #if !defined(_WIN32) && !defined(_WIN64) +#if defined(__MACH__) || defined(__APPLE__) + struct mach_task_basic_info t_info; + char name[2 * MAXCOMLEN] = {0}; + + proc_name(getpid(), name, sizeof(name)); + mach_msg_type_number_t t_info_count = MACH_TASK_BASIC_INFO_COUNT; + task_info(mach_task_self(), MACH_TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count); + + out << t_info.resident_size_max << '\t'; + out << t_info.resident_size << '\t'; + out << name << '\t'; +#else // Linux doesn't set memory usage in getrusage :-( std::set<std::string> headers; headers.insert("VmPeak:"); @@ -209,6 +222,7 @@ void PrintUsage(std::ostream &out) { out << header << SkipSpaces(value.c_str()) << '\t'; } } +#endif struct rusage usage; if (getrusage(RUSAGE_SELF, &usage)) { |