To my delight, I noticed that -e mmap --total and -e malloc --total work and show how much was allocated instead of how often :tada:. I think this deserves to be documented btw.
It would be cool if munmap and free would be treated the same. That way I could trace those pairs of events and see if they have the same width on the flame graph. Not every call to mmap is a leak, there are libraries that call mmap and munmap directly, e.g. some encryption libraries. It's only a problem if they mmap more than they munmap.
My plan is to generalize counting total of an arbitrary function that takes an integer argument. It will be possible to specify which argument to track: e.g. the first argument of malloc, or the second argument of mmap or munmap.
Unfortunately, free accepts only an address - it's hard to determine how much memory is freed. In theory, it's possible to sample malloc'ed addresses and match them with corresponding free calls - but I'm afraid it falls out of the scope of async-profiler. After all, some native allocators (like jemalloc) already have this feature.
I guess free isn't as important anyway, as mmap is how you see the live set increase.
Added munmap to the known list.
Also, it's now possible to specify which argument to use for total,
e.g. -e sendfile{4} means profile the fourth argument of sendfile().
Most helpful comment
Added
munmapto the known list.Also, it's now possible to specify which argument to use for
total,e.g.
-e sendfile{4}means profile the fourth argument of sendfile().