mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +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:
parent
787eb5e3ef
commit
5c5a7b9193
@ -51,8 +51,10 @@ size_t Process::GetMallocUsage() {
|
|||||||
struct mallinfo mi;
|
struct mallinfo mi;
|
||||||
mi = ::mallinfo();
|
mi = ::mallinfo();
|
||||||
return mi.uordblks;
|
return mi.uordblks;
|
||||||
#elif defined(HAVE_MSTATS) && defined(HAVE_MALLOC_MALLOC_H)
|
#elif defined(HAVE_MALLOC_ZONE_STATISTICS) && defined(HAVE_MALLOC_MALLOC_H)
|
||||||
return mstats().bytes_used; // darwin
|
malloc_statistics_t Stats;
|
||||||
|
malloc_zone_statistics(malloc_default_zone(), &Stats);
|
||||||
|
return Stats.size_in_use; // darwin
|
||||||
#elif defined(HAVE_SBRK)
|
#elif defined(HAVE_SBRK)
|
||||||
// Note this is only an approximation and more closely resembles
|
// Note this is only an approximation and more closely resembles
|
||||||
// the value returned by mallinfo in the arena field.
|
// the value returned by mallinfo in the arena field.
|
||||||
@ -74,8 +76,10 @@ Process::GetTotalMemoryUsage()
|
|||||||
#if defined(HAVE_MALLINFO)
|
#if defined(HAVE_MALLINFO)
|
||||||
struct mallinfo mi = ::mallinfo();
|
struct mallinfo mi = ::mallinfo();
|
||||||
return mi.uordblks + mi.hblkhd;
|
return mi.uordblks + mi.hblkhd;
|
||||||
#elif defined(HAVE_MSTATS) && defined(HAVE_MALLOC_MALLOC_H)
|
#elif defined(HAVE_MALLOC_ZONE_STATISTICS) && defined(HAVE_MALLOC_MALLOC_H)
|
||||||
return mstats().bytes_total; // darwin
|
malloc_statistics_t Stats;
|
||||||
|
malloc_zone_statistics(malloc_default_zone(), &Stats);
|
||||||
|
return Stats.size_allocated; // darwin
|
||||||
#elif defined(HAVE_GETRUSAGE)
|
#elif defined(HAVE_GETRUSAGE)
|
||||||
struct rusage usage;
|
struct rusage usage;
|
||||||
::getrusage(RUSAGE_SELF, &usage);
|
::getrusage(RUSAGE_SELF, &usage);
|
||||||
|
Loading…
Reference in New Issue
Block a user