< prev index next >

src/share/vm/services/mallocTracker.hpp

Print this page
rev 12121 : 8167650: NMT should check for invalid MEMFLAGS
Reviewed-by: dholmes, mockner


 124 
 125   DEBUG_ONLY(inline const MemoryCounter& malloc_counter() const { return _malloc; })
 126   DEBUG_ONLY(inline const MemoryCounter& arena_counter()  const { return _arena;  })
 127 };
 128 
 129 class MallocMemorySummary;
 130 
 131 // A snapshot of malloc'd memory, includes malloc memory
 132 // usage by types and memory used by tracking itself.
 133 class MallocMemorySnapshot : public ResourceObj {
 134   friend class MallocMemorySummary;
 135 
 136  private:
 137   MallocMemory      _malloc[mt_number_of_types];
 138   MemoryCounter     _tracking_header;
 139 
 140 
 141  public:
 142   inline MallocMemory*  by_type(MEMFLAGS flags) {
 143     int index = NMTUtil::flag_to_index(flags);

 144     return &_malloc[index];
 145   }
 146 
 147   inline MallocMemory* by_index(int index) {
 148     assert(index >= 0, "Index out of bound");
 149     assert(index < mt_number_of_types, "Index out of bound");
 150     return &_malloc[index];
 151   }
 152 
 153   inline MemoryCounter* malloc_overhead() {
 154     return &_tracking_header;
 155   }
 156 
 157   // Total malloc'd memory amount
 158   size_t total() const;
 159   // Total malloc'd memory used by arenas
 160   size_t total_arena() const;
 161 
 162   inline size_t thread_count() const {
 163     MallocMemorySnapshot* s = const_cast<MallocMemorySnapshot*>(this);




 124 
 125   DEBUG_ONLY(inline const MemoryCounter& malloc_counter() const { return _malloc; })
 126   DEBUG_ONLY(inline const MemoryCounter& arena_counter()  const { return _arena;  })
 127 };
 128 
 129 class MallocMemorySummary;
 130 
 131 // A snapshot of malloc'd memory, includes malloc memory
 132 // usage by types and memory used by tracking itself.
 133 class MallocMemorySnapshot : public ResourceObj {
 134   friend class MallocMemorySummary;
 135 
 136  private:
 137   MallocMemory      _malloc[mt_number_of_types];
 138   MemoryCounter     _tracking_header;
 139 
 140 
 141  public:
 142   inline MallocMemory*  by_type(MEMFLAGS flags) {
 143     int index = NMTUtil::flag_to_index(flags);
 144     assert(index >= 0 && index < mt_number_of_types, "Index out of bound");
 145     return &_malloc[index];
 146   }
 147 
 148   inline MallocMemory* by_index(int index) {
 149     assert(index >= 0, "Index out of bound");
 150     assert(index < mt_number_of_types, "Index out of bound");
 151     return &_malloc[index];
 152   }
 153 
 154   inline MemoryCounter* malloc_overhead() {
 155     return &_tracking_header;
 156   }
 157 
 158   // Total malloc'd memory amount
 159   size_t total() const;
 160   // Total malloc'd memory used by arenas
 161   size_t total_arena() const;
 162 
 163   inline size_t thread_count() const {
 164     MallocMemorySnapshot* s = const_cast<MallocMemorySnapshot*>(this);


< prev index next >