我如何使用valgrind作为内存配置文件

时间:2022-03-17 19:38:28

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)?

你能否告诉我如何使用valgrind作为内存配置文件?我从谷歌发现的文章谈到了如何使用valgrind进行内存泄漏。我感兴趣的是如何使用它进行内存分析(即什么类使用了多少内存)?

Thank you.

谢谢。

1 个解决方案

#1


10  

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.

您可以使用valgrind的Massif工具来获取堆配置文件。此代码仍标记为“experimental”,并且不附带所有版本的valgrind。您可能必须从源代码下载和构建。

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.

但是,即使不支持类,Massif配置文件也可能有用。

#1


10  

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.

您可以使用valgrind的Massif工具来获取堆配置文件。此代码仍标记为“experimental”,并且不附带所有版本的valgrind。您可能必须从源代码下载和构建。

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.

但是,即使不支持类,Massif配置文件也可能有用。