* See prof_sample_threshold_update() comment for why the body of this function * is conditionally compiled. */
| 1764 | * is conditionally compiled. |
| 1765 | */ |
| 1766 | static void |
| 1767 | prof_leakcheck(const prof_cnt_t *cnt_all, size_t leak_ngctx, |
| 1768 | const char *filename) { |
| 1769 | #ifdef JEMALLOC_PROF |
| 1770 | /* |
| 1771 | * Scaling is equivalent AdjustSamples() in jeprof, but the result may |
| 1772 | * differ slightly from what jeprof reports, because here we scale the |
| 1773 | * summary values, whereas jeprof scales each context individually and |
| 1774 | * reports the sums of the scaled values. |
| 1775 | */ |
| 1776 | if (cnt_all->curbytes != 0) { |
| 1777 | double sample_period = (double)((uint64_t)1 << lg_prof_sample); |
| 1778 | double ratio = (((double)cnt_all->curbytes) / |
| 1779 | (double)cnt_all->curobjs) / sample_period; |
| 1780 | double scale_factor = 1.0 / (1.0 - exp(-ratio)); |
| 1781 | uint64_t curbytes = (uint64_t)round(((double)cnt_all->curbytes) |
| 1782 | * scale_factor); |
| 1783 | uint64_t curobjs = (uint64_t)round(((double)cnt_all->curobjs) * |
| 1784 | scale_factor); |
| 1785 | |
| 1786 | malloc_printf("<jemalloc>: Leak approximation summary: ~%"FMTu64 |
| 1787 | " byte%s, ~%"FMTu64" object%s, >= %zu context%s\n", |
| 1788 | curbytes, (curbytes != 1) ? "s" : "", curobjs, (curobjs != |
| 1789 | 1) ? "s" : "", leak_ngctx, (leak_ngctx != 1) ? "s" : ""); |
| 1790 | malloc_printf( |
| 1791 | "<jemalloc>: Run jeprof on \"%s\" for leak detail\n", |
| 1792 | filename); |
| 1793 | } |
| 1794 | #endif |
| 1795 | } |
| 1796 | |
| 1797 | struct prof_gctx_dump_iter_arg_s { |
| 1798 | tsdn_t *tsdn; |
no test coverage detected