跟踪C ++内存分配 [英] track C++ memory allocations

查看:142
本文介绍了跟踪C ++内存分配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来跟踪C ++程序中的内存分配。我不是对内存泄漏感兴趣,这似乎是大多数工具试图找到,而是为应用程序创建内存使用配置文件。理想输出将是一个大的函数名称列表加上最大分配的字节数随时间或更好,但堆,随着时间的图形表示。水平轴是时间,垂直轴堆空间。每个函数都会得到它自己的颜色,并根据分配的堆字节绘制线。用于标识分配的对象类型的奖励点。

I am looking for a way to track memory allocations in a C++ program. I am not interested in memory leaks, which seem to be what most tools are trying to find, but rather creating a memory usage profile for the application. Ideal output would be either a big list of function names plus number of maximum allocated bytes over time or better yet, a graphical representation of the heap over time. Horizontal axis is time, vertical axis heap space. Every function would get it's own color and draw lines according to allocated heap bytes. Bonus points for identifying allocated object types as well.

这个想法是找到内存瓶颈/可视化哪些函数/线程消耗最多的内存,并且应该被进一步优化。

The idea is to find memory bottlenecks/to visualize what functions/threads consume the most memory and should be targetted for further optimization.

我简单看了一下Purify,BoundsChecker和AQTime,但是他们似乎不是我的追求。 Valgrind看起来合适,但是,我在Windows上。 Memtrack 看起来很有希望,但需要对源代码进行重大更改。

I have briefly looked at Purify, BoundsChecker and AQTime but they don't seem to be what I'm after. Valgrind looks suitable, however, I'm on Windows. Memtrack looks promising, but requires significant changes to the source code.

我的google技巧一定失败了我,因为它似乎不是这样一个罕见的要求?创建这样一个工具所需的所有信息都应该可以从程序的调试符号加上运行时API调用 - 否?

My google skills must have failed me, cause it doesn't seem to be such an uncommon request? All the needed information to create a tool like that should be readily available from the program's debug symbols plus runtime API calls - no?

推荐答案

监控您电脑的内存使用情况以进行游戏开发包含了我所寻找的几乎完美的例子。它花了一段时间,让它运行,但文章的作者是非常有益的。您可以在 Memtracer 中找到该工具的源代码。

Monitoring Your PC's Memory Usage For Game Development contains a nearly perfect example of what I was looking for. It took a while to get it running but the author of the article was very helpful. You can find the source code for the tool here Memtracer.

我也在 SWENG (软件工程邮件列表)上获得了很多有用的答案。该线程被称为[Sweng-Gamedev]监视C ++内存使用?。

I also got a lot of helpful answers on the SWENG (Software Engineering Mailing List). The thread is called "[Sweng-Gamedev] monitoring C++ memory usage?".

这篇关于跟踪C ++内存分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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