How can I use valgrind for memory profile

2019-04-07 02:20发布

Can you please tell me how can I use valgrind for memory profile? The article I found from google talks about how to use valgrind for memory leak. I am interested in how to use that for memory profiling (i.e. how much memory is used by what classes)?

Thank you.

1条回答
贼婆χ
2楼-- · 2019-04-07 02:46

You can use valgrind's Massif tool to get a heap profile. This code is still labelled "experimental", and it does not ship with all versions of valgrind. You may have to download and build from source.

Also note that the heap profile is organized by allocation site, which is a finer granularity than classes. If you need information organized by class, you will have to read the developer documentation and get the machine-readable format, then figure out which allocation sites go with which classes - perhaps with support from your compiler.

Even without support for classes, however, the Massif profile may be useful.

查看更多
登录 后发表回答