问题描述
我正在编写一个应用程序,我惊讶地发现它的总内存使用量已经太高了。我想分析我的应用程序的动态内存使用:每种类型的对象有多少对象在堆中,哪些函数创建这些对象?此外,每个对象使用多少内存?
I am writing an application and am surprised to see its total memory usage is already too high. I want to profile the dynamic memory usage of my application: How many objects of each kind are there in the heap, and which functions created these objects? Also, how much memory is used by each of the object?
有没有简单的方法来做到这一点?我在linux和windows上工作,所以任何平台的工具就足够了。
Is there a simple way to do this? I am working on both linux and windows, so tools of any of the platforms would suffice.
注意:我不关心这里的内存泄漏。
NOTE: I am not concerned with memory leaks here.
推荐答案
您是否尝试过?它是一个Linux的性能分析工具。它有一个内存检查器(内存泄漏和其他内存问题)称为Memcheck,但它也有一个名为Massif的堆分析器。
Have you tried Valgrind? It is a profiling tool for Linux. It has a memory checker (for memory leaks and other memory problems) called Memcheck but it has also a heap profiler named Massif.
这篇关于C ++中的内存分配分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!