List all live malloc'd blocks, with their size in bytes
jasone at canonware.com
Wed Jul 25 09:37:13 PDT 2012
On Jul 24, 2012, at 6:47 PM, Benoit Jacob wrote:
> I would like to know if jemalloc 3.0 is able to give a list of all
> currently live blocks, with their exact address and size.
> By "live block" I mean something that has been returned by malloc (or
> realloc, etc) and not yet free'd.
> If that is not possible, is there a "right way" to do so as a local
> patch to my version of jemalloc (with no particular aim at upstreaming
> this), or should I simply just instrument the malloc, free, etc.
jemalloc 3 doesn't maintain the data structures necessary to iterate over live blocks, though it would be possible if arenas kept track of all associated chunks so that the chunks could be iterated over. Several years ago jemalloc had this ability, but I removed it because iteration was quite difficult to safely use (no allocation allowed), and the extra data structure overhead didn't seem warranted, given that the functionality was almost never used.
Thread caches throw a monkey wrench in things, because from the perspective of arena data structures, cached blocks are allocated. Therefore, it would be necessary to somehow cancel out the effects of caching, by disabling caching, flushing caches before iteration, or masking the cached blocks during iteration.
More information about the jemalloc-discuss