diff options
author | Chris Lattner <sabre@nondot.org> | 2005-11-14 07:27:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-11-14 07:27:56 +0000 |
commit | c590e9afc9a06509638abe744543e49ea45f6f20 (patch) | |
tree | 0dbbbff3e8611619639075fe124e57b7aefd4e55 /lib/System | |
parent | 511f11dccb7c261b9d7e7d95299930283f6f6589 (diff) | |
download | external_llvm-c590e9afc9a06509638abe744543e49ea45f6f20.zip external_llvm-c590e9afc9a06509638abe744543e49ea45f6f20.tar.gz external_llvm-c590e9afc9a06509638abe744543e49ea45f6f20.tar.bz2 |
instead of using mstats, use malloc_zone_statistics which returns numbers
that actually make sense.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24352 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System')
-rw-r--r-- | lib/System/Unix/Process.inc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/System/Unix/Process.inc b/lib/System/Unix/Process.inc index f73444f..32733d6 100644 --- a/lib/System/Unix/Process.inc +++ b/lib/System/Unix/Process.inc @@ -51,8 +51,10 @@ size_t Process::GetMallocUsage() { struct mallinfo mi; mi = ::mallinfo(); return mi.uordblks; -#elif defined(HAVE_MSTATS) && defined(HAVE_MALLOC_MALLOC_H) - return mstats().bytes_used; // darwin +#elif defined(HAVE_MALLOC_ZONE_STATISTICS) && defined(HAVE_MALLOC_MALLOC_H) + malloc_statistics_t Stats; + malloc_zone_statistics(malloc_default_zone(), &Stats); + return Stats.size_in_use; // darwin #elif defined(HAVE_SBRK) // Note this is only an approximation and more closely resembles // the value returned by mallinfo in the arena field. @@ -74,8 +76,10 @@ Process::GetTotalMemoryUsage() #if defined(HAVE_MALLINFO) struct mallinfo mi = ::mallinfo(); return mi.uordblks + mi.hblkhd; -#elif defined(HAVE_MSTATS) && defined(HAVE_MALLOC_MALLOC_H) - return mstats().bytes_total; // darwin +#elif defined(HAVE_MALLOC_ZONE_STATISTICS) && defined(HAVE_MALLOC_MALLOC_H) + malloc_statistics_t Stats; + malloc_zone_statistics(malloc_default_zone(), &Stats); + return Stats.size_allocated; // darwin #elif defined(HAVE_GETRUSAGE) struct rusage usage; ::getrusage(RUSAGE_SELF, &usage); |