X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/736a6a291cf0fc9ab9410f300174a70e868e4122..e5a2b8544dee410dcdeafbc2f1b82f9a8f4faf23:/main.c diff --git a/main.c b/main.c index c092bd23..89388373 100644 --- a/main.c +++ b/main.c @@ -2,7 +2,7 @@ Copyright (C) 1996-2001 by Andrew Tridgell Copyright (C) Paul Mackerras 1996 - Copyright (C) 2001 by Martin Pool + Copyright (C) 2001, 2002 by Martin Pool This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ struct stats stats; extern int verbose; +static void show_malloc_stats(void); /**************************************************************************** wait for a process to exit, calling io_flush while waiting @@ -119,6 +120,7 @@ static void report(int f) rprintf(FINFO,"total size is %.0f speedup is %.2f\n", (double)stats.total_size, (1.0*stats.total_size)/(stats.total_written+stats.total_read)); + show_malloc_stats(); } fflush(stdout); @@ -126,6 +128,31 @@ static void report(int f) } +/** + * If our C library can get malloc statistics, then show them to FINFO + **/ +static void show_malloc_stats(void) +{ +#ifdef HAVE_MALLINFO + struct mallinfo mi; + + mi = mallinfo(); + + rprintf(FINFO, RSYNC_NAME " heap statistics:\n"); + rprintf(FINFO, " arena: %10d (bytes from sbrk)\n", mi.arena); + rprintf(FINFO, " ordblks: %10d (chunks not in use)\n", mi.ordblks); + rprintf(FINFO, " smblks: %10d\n", mi.smblks); + rprintf(FINFO, " hblks: %10d (chunks from mmap)\n", mi.hblks); + rprintf(FINFO, " hblkhd: %10d (bytes from mmap)\n", mi.hblkhd); + rprintf(FINFO, " usmblks: %10d\n", mi.usmblks); + rprintf(FINFO, " fsmblks: %10d\n", mi.fsmblks); + rprintf(FINFO, " uordblks: %10d (bytes used)\n", mi.uordblks); + rprintf(FINFO, " fordblks: %10d (bytes free)\n", mi.fordblks); + rprintf(FINFO, " keepcost: %10d (bytes in releasable chunk)\n", mi.keepcost); +#endif /* HAVE_MALLINFO */ +} + + /* Start the remote shell. cmd may be NULL to use the default. */ static pid_t do_cmd(char *cmd,char *machine,char *user,char *path,int *f_in,int *f_out) {