mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
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
This commit is contained in:
parent
511f11dccb
commit
c590e9afc9
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user