147 assert(index >= 0, "Index out of bound"); 148 assert(index < mt_number_of_types, "Index out of bound"); 149 return &_malloc[index]; 150 } 151 152 inline MemoryCounter* malloc_overhead() { 153 return &_tracking_header; 154 } 155 156 // Total malloc'd memory amount 157 size_t total() const; 158 // Total malloc'd memory used by arenas 159 size_t total_arena() const; 160 161 inline size_t thread_count() const { 162 MallocMemorySnapshot* s = const_cast<MallocMemorySnapshot*>(this); 163 return s->by_type(mtThreadStack)->malloc_count(); 164 } 165 166 void copy_to(MallocMemorySnapshot* s) { 167 s->_tracking_header = _tracking_header; 168 for (int index = 0; index < mt_number_of_types; index ++) { 169 s->_malloc[index] = _malloc[index]; 170 } 171 } 172 173 // Make adjustment by subtracting chunks used by arenas 174 // from total chunks to get total free chunk size 175 void make_adjustment(); 176 }; 177 178 /* 179 * This class is for collecting malloc statistics at summary level 180 */ 181 class MallocMemorySummary : AllStatic { 182 private: 183 // Reserve memory for placement of MallocMemorySnapshot object 184 static size_t _snapshot[CALC_OBJ_SIZE_IN_TYPE(MallocMemorySnapshot, size_t)]; 185 186 public: | 147 assert(index >= 0, "Index out of bound"); 148 assert(index < mt_number_of_types, "Index out of bound"); 149 return &_malloc[index]; 150 } 151 152 inline MemoryCounter* malloc_overhead() { 153 return &_tracking_header; 154 } 155 156 // Total malloc'd memory amount 157 size_t total() const; 158 // Total malloc'd memory used by arenas 159 size_t total_arena() const; 160 161 inline size_t thread_count() const { 162 MallocMemorySnapshot* s = const_cast<MallocMemorySnapshot*>(this); 163 return s->by_type(mtThreadStack)->malloc_count(); 164 } 165 166 void copy_to(MallocMemorySnapshot* s) { 167 // Need to make sure that mtChunks don't get deallocated while the 168 // copy is going on, because their size is adjusted using this 169 // buffer in make_adjustment(). 170 ThreadCritical tc; 171 s->_tracking_header = _tracking_header; 172 for (int index = 0; index < mt_number_of_types; index ++) { 173 s->_malloc[index] = _malloc[index]; 174 } 175 } 176 177 // Make adjustment by subtracting chunks used by arenas 178 // from total chunks to get total free chunk size 179 void make_adjustment(); 180 }; 181 182 /* 183 * This class is for collecting malloc statistics at summary level 184 */ 185 class MallocMemorySummary : AllStatic { 186 private: 187 // Reserve memory for placement of MallocMemorySnapshot object 188 static size_t _snapshot[CALC_OBJ_SIZE_IN_TYPE(MallocMemorySnapshot, size_t)]; 189 190 public: |