* If our C library can get malloc statistics, then show them to FINFO **/
| 478 | * If our C library can get malloc statistics, then show them to FINFO |
| 479 | **/ |
| 480 | static void show_malloc_stats(void) |
| 481 | { |
| 482 | #ifdef MEM_ALLOC_INFO |
| 483 | struct MEM_ALLOC_INFO mi = MEM_ALLOC_INFO(); /* mallinfo or mallinfo2 */ |
| 484 | |
| 485 | rprintf(FCLIENT, "\n"); |
| 486 | rprintf(FINFO, RSYNC_NAME "[%d] (%s%s%s) heap statistics:\n", |
| 487 | (int)getpid(), am_server ? "server " : "", |
| 488 | am_daemon ? "daemon " : "", who_am_i()); |
| 489 | |
| 490 | #define PRINT_ALLOC_NUM(title, descr, num) \ |
| 491 | rprintf(FINFO, " %-11s%10" SIZE_T_FMT_MOD "d (" descr ")\n", \ |
| 492 | title ":", (SIZE_T_FMT_CAST)(num)); |
| 493 | |
| 494 | PRINT_ALLOC_NUM("arena", "bytes from sbrk", mi.arena); |
| 495 | PRINT_ALLOC_NUM("ordblks", "chunks not in use", mi.ordblks); |
| 496 | PRINT_ALLOC_NUM("smblks", "free fastbin blocks", mi.smblks); |
| 497 | PRINT_ALLOC_NUM("hblks", "chunks from mmap", mi.hblks); |
| 498 | PRINT_ALLOC_NUM("hblkhd", "bytes from mmap", mi.hblkhd); |
| 499 | PRINT_ALLOC_NUM("allmem", "bytes from sbrk + mmap", mi.arena + mi.hblkhd); |
| 500 | PRINT_ALLOC_NUM("usmblks", "always 0", mi.usmblks); |
| 501 | PRINT_ALLOC_NUM("fsmblks", "bytes in freed fastbin blocks", mi.fsmblks); |
| 502 | PRINT_ALLOC_NUM("uordblks", "bytes used", mi.uordblks); |
| 503 | PRINT_ALLOC_NUM("fordblks", "bytes free", mi.fordblks); |
| 504 | PRINT_ALLOC_NUM("keepcost", "bytes in releasable chunk", mi.keepcost); |
| 505 | |
| 506 | #undef PRINT_ALLOC_NUM |
| 507 | |
| 508 | #endif /* MEM_ALLOC_INFO */ |
| 509 | } |
| 510 | |
| 511 | |
| 512 | /* Start the remote shell. cmd may be NULL to use the default. */ |
no test coverage detected