// Used by TrackedAllocators. enum AllocatorTag {
kAllocatorTagHeap,
kAllocatorTagMonitorList,
kAllocatorTagClassTable,
kAllocatorTagInternTable,
kAllocatorTagMaps,
kAllocatorTagLOS,
kAllocatorTagSafeMap,
kAllocatorTagLOSMaps,
kAllocatorTagReferenceTable,
kAllocatorTagHeapBitmap,
kAllocatorTagHeapBitmapLOS,
kAllocatorTagMonitorPool,
kAllocatorTagLOSFreeList,
kAllocatorTagVerifier,
kAllocatorTagRememberedSet,
kAllocatorTagModUnionCardSet,
kAllocatorTagModUnionReferenceArray,
kAllocatorTagJNILibraries,
kAllocatorTagCompileTimeClassPath,
kAllocatorTagOatFile,
kAllocatorTagDexFileVerifier,
kAllocatorTagRosAlloc,
kAllocatorTagCount, // Must always be last element.
};
std::ostream& operator<<(std::ostream& os, AllocatorTag tag);
namespace TrackedAllocators {
// We use memory_order_relaxed updates of the following counters. Values are treated as approximate // wherever concurrent updates are possible. // Running count of number of bytes used for this kind of allocation. Increased by allocations, // decreased by deallocations. extern Atomic<size_t> g_bytes_used[kAllocatorTagCount];
// Largest value of bytes used seen. extern Atomic<size_t> g_max_bytes_used[kAllocatorTagCount];
// Total number of bytes allocated of this kind. extern Atomic<uint64_t> g_total_bytes_used[kAllocatorTagCount];
// Tracking allocator for use with STL types, tracks how much memory is used. template <class T, AllocatorTag kTag> class TrackingAllocatorImpl {
static_assert(kTag < kAllocatorTagCount, "kTag must be less than kAllocatorTagCount");
public: using value_type = T;
// Used internally by STL data structures. This copy constructor needs to be implicit. Don't wrap // the line because that would break cpplint's detection of the implicit constructor. template <class U>
TrackingAllocatorImpl([[maybe_unused]] const TrackingAllocatorImpl<U, kTag>& alloc) noexcept {} // NOLINT [runtime/explicit] // Used internally by STL data structures.
TrackingAllocatorImpl() noexcept {}
// Enables an allocator for objects of one type to allocate storage for objects of another type. // Used internally by STL data structures. template <class U> struct rebind { using other = TrackingAllocatorImpl<U, kTag>;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.