1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

instead of using mstats, use malloc_zone_statistics which returns numbers

that actually make sense.

llvm-svn: 24352
This commit is contained in:
Chris Lattner 2005-11-14 07:27:56 +00:00
parent 787eb5e3ef
commit 5c5a7b9193

View File

@ -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);