Memory Allocation Profiling in C++(C++ 中的内存分配分析)
问题描述
我正在编写一个应用程序,并惊讶地发现它的总内存使用量已经太高了.我想分析我的应用程序的动态内存使用情况:堆中每种类型的对象有多少,哪些函数创建了这些对象?另外,每个对象使用了多少内存?
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.
推荐答案
您是否尝试过 Valgrind?它是 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++ 中的内存分配分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++ 中的内存分配分析


基础教程推荐
- 这个宏可以转换成函数吗? 2022-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 我有静态或动态 boost 库吗? 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何在 C++ 中初始化静态常量成员? 2022-01-01