Async-profiler: Add munmap and free to known functions

Created on 22 Apr 2021  路  3Comments  路  Source: jvm-profiling-tools/async-profiler

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.

enhancement

Most helpful comment

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().

All 3 comments

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().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ceeaspb picture ceeaspb  路  5Comments

ceeaspb picture ceeaspb  路  6Comments

franz1981 picture franz1981  路  8Comments

stsypanov picture stsypanov  路  5Comments

franz1981 picture franz1981  路  4Comments