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++ 中的内存分配分析
基础教程推荐
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07