Search code examples
memory-leaksjemalloc

Is jemalloc heap profiling tracking allocations only?


I'm trying to solve some memory leaks, and I'm using jemalloc to dump heap profiles: MALLOC_CONF=prof:true,lg_prof_interval:30,lg_prof_sample:17

Works as charm, but I don't know what I'm looking at :)

Does jemaloc heap profiling show all (sampled) allocations, or just the ones that haven't been free()-ed at the moment of taking a dump? Or to put it differently: is it an allocation profile, or "live" blocks profile?


Solution

  • My understanding is by default, jeprof shows allocations that are "live" at the time the dump is written. You can change that however.

    See the jeprofile prof_accum option if you want to record all allocations: http://jemalloc.net/jemalloc.3.html#opt.prof_accum

    You may also need the --alloc_space jeprof flag to display allocated bytes instead of the in use ones: https://github.com/jemalloc/jemalloc/blob/dev/bin/jeprof.in#L208