diff options
Diffstat (limited to 'runtime/base/allocator.cc')
-rw-r--r-- | runtime/base/allocator.cc | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/runtime/base/allocator.cc b/runtime/base/allocator.cc index 64cdbbf..f67616e 100644 --- a/runtime/base/allocator.cc +++ b/runtime/base/allocator.cc @@ -25,10 +25,6 @@ namespace art { -Atomic<uint64_t> TrackedAllocators::bytes_used_[kAllocatorTagCount]; -Atomic<uint64_t> TrackedAllocators::max_bytes_used_[kAllocatorTagCount]; -Atomic<uint64_t> TrackedAllocators::total_bytes_used_[kAllocatorTagCount]; - class MallocAllocator FINAL : public Allocator { public: explicit MallocAllocator() {} @@ -76,13 +72,19 @@ Allocator* Allocator::GetNoopAllocator() { return &g_noop_allocator; } -void TrackedAllocators::Dump(std::ostream& os) { +namespace TrackedAllocators { + +Atomic<size_t> g_bytes_used[kAllocatorTagCount]; +volatile size_t g_max_bytes_used[kAllocatorTagCount]; +Atomic<uint64_t> g_total_bytes_used[kAllocatorTagCount]; + +void Dump(std::ostream& os) { if (kEnableTrackingAllocator) { os << "Dumping native memory usage\n"; for (size_t i = 0; i < kAllocatorTagCount; ++i) { - uint64_t bytes_used = bytes_used_[i].LoadRelaxed(); - uint64_t max_bytes_used = max_bytes_used_[i].LoadRelaxed(); - uint64_t total_bytes_used = total_bytes_used_[i].LoadRelaxed(); + uint64_t bytes_used = g_bytes_used[i].LoadRelaxed(); + uint64_t max_bytes_used = g_max_bytes_used[i]; + uint64_t total_bytes_used = g_total_bytes_used[i].LoadRelaxed(); if (total_bytes_used != 0) { os << static_cast<AllocatorTag>(i) << " active=" << bytes_used << " max=" << max_bytes_used << " total=" << total_bytes_used << "\n"; @@ -91,4 +93,6 @@ void TrackedAllocators::Dump(std::ostream& os) { } } +} // namespace TrackedAllocators + } // namespace art |