MCPcopy Create free account
hub / github.com/RsyncProject/rsync / show_malloc_stats

Function show_malloc_stats

main.c:480–509  ·  view source on GitHub ↗

* If our C library can get malloc statistics, then show them to FINFO **/

Source from the content-addressed store, hash-verified

478 * If our C library can get malloc statistics, then show them to FINFO
479 **/
480static 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. */

Callers 1

handle_statsFunction · 0.85

Calls 3

MEM_ALLOC_INFOClass · 0.85
rprintfFunction · 0.70
who_am_iFunction · 0.70

Tested by

no test coverage detected