Memory profiling is used to detect inefficient usage of dynamic memory and memory leaks. Some use cases for the memory profiler are:
the service is running out of RAM (RSS), which creates problems in production right up to the point of the OOM killer.
there are suspicions of a memory leak. For example, the RSS usage is constantly growing and does not reach a plateau until the service is restarted.
there are arguments in favor of the fact that the service will soon experience a shortage of RSS. For example, due to the growth of caches or other internal structures by an order of magnitude.
$ curl -X POST localhost:1188/service/jemalloc/prof/disable
OK
$ curl -s -X POST localhost:1188/service/jemalloc/prof/stat | grep ' prof.active:'
prof.active: false
How to analyse the dump
To decrypt the dump file, you need the binary files of your service and dynamic libraries with which the process was launched during profiling. Therefore, it is recommended to run jeprof on the target machine and parse the resulting pdf/text file on your working machine. To install jeprof, you can do apt install libjemalloc-dev.
If you want to get a call graph with notes about the allocated memory, use the command: