154 inline MallocMemory* by_type(MEMFLAGS flags) { 155 int index = NMTUtil::flag_to_index(flags); 156 return &_malloc[index]; 157 } 158 159 inline MallocMemory* by_index(int index) { 160 assert(index >= 0, "Index out of bound"); 161 assert(index < mt_number_of_types, "Index out of bound"); 162 return &_malloc[index]; 163 } 164 165 inline MemoryCounter* malloc_overhead() { 166 return &_tracking_header; 167 } 168 169 // Total malloc'd memory amount 170 size_t total() const; 171 // Total malloc'd memory used by arenas 172 size_t total_arena() const; 173 174 inline size_t thread_count() { 175 return by_type(mtThreadStack)->malloc_count(); 176 } 177 178 void reset(); 179 180 void copy_to(MallocMemorySnapshot* s) { 181 s->_tracking_header = _tracking_header; 182 for (int index = 0; index < mt_number_of_types; index ++) { 183 s->_malloc[index] = _malloc[index]; 184 } 185 } 186 187 // Make adjustment by subtracting chunks used by arenas 188 // from total chunks to get total free chunk size 189 void make_adjustment(); 190 }; 191 192 /* 193 * This class is for collecting malloc statistics at summary level 194 */ 195 class MallocMemorySummary : AllStatic { | 154 inline MallocMemory* by_type(MEMFLAGS flags) { 155 int index = NMTUtil::flag_to_index(flags); 156 return &_malloc[index]; 157 } 158 159 inline MallocMemory* by_index(int index) { 160 assert(index >= 0, "Index out of bound"); 161 assert(index < mt_number_of_types, "Index out of bound"); 162 return &_malloc[index]; 163 } 164 165 inline MemoryCounter* malloc_overhead() { 166 return &_tracking_header; 167 } 168 169 // Total malloc'd memory amount 170 size_t total() const; 171 // Total malloc'd memory used by arenas 172 size_t total_arena() const; 173 174 inline size_t thread_count() const { 175 MallocMemorySnapshot* s = const_cast<MallocMemorySnapshot*>(this); 176 return s->by_type(mtThreadStack)->malloc_count(); 177 } 178 179 void reset(); 180 181 void copy_to(MallocMemorySnapshot* s) { 182 s->_tracking_header = _tracking_header; 183 for (int index = 0; index < mt_number_of_types; index ++) { 184 s->_malloc[index] = _malloc[index]; 185 } 186 } 187 188 // Make adjustment by subtracting chunks used by arenas 189 // from total chunks to get total free chunk size 190 void make_adjustment(); 191 }; 192 193 /* 194 * This class is for collecting malloc statistics at summary level 195 */ 196 class MallocMemorySummary : AllStatic { |