C++ 中的内存分配分析 [英] Memory Allocation Profiling in C++

查看:24
本文介绍了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++ 中的内存分配分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆