diff --git a/include/jemalloc/internal/prof_data.h b/include/jemalloc/internal/prof_data.h index d7c3c521..4c8e22c7 100644 --- a/include/jemalloc/internal/prof_data.h +++ b/include/jemalloc/internal/prof_data.h @@ -10,8 +10,8 @@ extern malloc_mutex_t prof_dump_mtx; extern malloc_mutex_t *gctx_locks; extern malloc_mutex_t *tdata_locks; -extern size_t prof_unbiased_sz[SC_NSIZES]; -extern size_t prof_shifted_unbiased_cnt[SC_NSIZES]; +extern size_t prof_unbiased_sz[PROF_SC_NSIZES]; +extern size_t prof_shifted_unbiased_cnt[PROF_SC_NSIZES]; void prof_bt_hash(const void *key, size_t r_hash[2]); bool prof_bt_keycomp(const void *k1, const void *k2); diff --git a/include/jemalloc/internal/prof_types.h b/include/jemalloc/internal/prof_types.h index dbd758fa..ba628654 100644 --- a/include/jemalloc/internal/prof_types.h +++ b/include/jemalloc/internal/prof_types.h @@ -39,6 +39,14 @@ typedef struct prof_recent_s prof_recent_t; # define PROF_DUMP_BUFSIZE 65536 #endif +/* Size of size class related tables */ +#ifdef JEMALLOC_PROF +# define PROF_SC_NSIZES SC_NSIZES +#else +/* Minimize memory bloat for non-prof builds. */ +# define PROF_SC_NSIZES 1 +#endif + /* Size of stack-allocated buffer used by prof_printf(). */ #define PROF_PRINTF_BUFSIZE 128 diff --git a/src/prof.c b/src/prof.c index 0c12c492..d50cbe34 100644 --- a/src/prof.c +++ b/src/prof.c @@ -89,6 +89,8 @@ prof_alloc_rollback(tsd_t *tsd, prof_tctx_t *tctx) { void prof_malloc_sample_object(tsd_t *tsd, const void *ptr, size_t size, size_t usize, prof_tctx_t *tctx) { + cassert(config_prof); + if (opt_prof_sys_thread_name) { prof_sys_thread_name_fetch(tsd); } @@ -133,6 +135,8 @@ prof_malloc_sample_object(tsd_t *tsd, const void *ptr, size_t size, void prof_free_sampled_object(tsd_t *tsd, size_t usize, prof_info_t *prof_info) { + cassert(config_prof); + assert(prof_info != NULL); prof_tctx_t *tctx = prof_info->alloc_tctx; assert((uintptr_t)tctx > (uintptr_t)1U); diff --git a/src/prof_data.c b/src/prof_data.c index 8dd1fd0e..63349850 100644 --- a/src/prof_data.c +++ b/src/prof_data.c @@ -59,8 +59,8 @@ static ckh_t bt2gctx; */ static prof_tdata_tree_t tdatas; -size_t prof_unbiased_sz[SC_NSIZES]; -size_t prof_shifted_unbiased_cnt[SC_NSIZES]; +size_t prof_unbiased_sz[PROF_SC_NSIZES]; +size_t prof_shifted_unbiased_cnt[PROF_SC_NSIZES]; /******************************************************************************/ /* Red-black trees. */