Get stats into "r". Also get per-size-class counts if class_count != NULL
| 313 | |
| 314 | // Get stats into "r". Also get per-size-class counts if class_count != NULL |
| 315 | static void ExtractStats(TCMallocStats* r, uint64_t* class_count) { |
| 316 | r->central_bytes = 0; |
| 317 | r->transfer_bytes = 0; |
| 318 | for (unsigned int cl = 0; cl < kNumClasses; ++cl) { |
| 319 | const int length = Static::central_cache()[cl].length(); |
| 320 | const int tc_length = Static::central_cache()[cl].tc_length(); |
| 321 | const size_t size = static_cast<uint64_t>( |
| 322 | Static::sizemap()->ByteSizeForClass(cl)); |
| 323 | r->central_bytes += (size * length); |
| 324 | r->transfer_bytes += (size * tc_length); |
| 325 | if (class_count) class_count[cl] = length + tc_length; |
| 326 | } |
| 327 | |
| 328 | // Add stats from per-thread heaps |
| 329 | r->thread_bytes = 0; |
| 330 | { // scope |
| 331 | SpinLockHolder h(Static::pageheap_lock()); |
| 332 | ThreadCache::GetThreadStats(&r->thread_bytes, class_count); |
| 333 | } |
| 334 | |
| 335 | { //scope |
| 336 | SpinLockHolder h(Static::pageheap_lock()); |
| 337 | r->system_bytes = Static::pageheap()->SystemBytes(); |
| 338 | r->metadata_bytes = tcmalloc::metadata_system_bytes(); |
| 339 | r->pageheap_bytes = Static::pageheap()->FreeBytes(); |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | // WRITE stats to "out" |
| 344 | static void DumpStats(TCMalloc_Printer* out, int level) { |
no test coverage detected