【问题标题】:Is there any tool that supports checkpoint based memory usage profiling for C++是否有任何工具支持基于检查点的 C++ 内存使用分析
【发布时间】:2012-09-13 10:23:06
【问题描述】:

我正在开发基于网络的应用程序。我想查看应用程序不同阶段之间的内存使用情况,例如初始化和释放之间的内存使用情况或发送和接收之间的内存使用情况。我已经用谷歌搜索并试图找到一个解决方案,但没有完全符合我要求的帖子。

请你们推荐任何可以帮助我在 Linux 和 Windows 平台上执行基于检查点内存分析的工具或过程。

提前致谢


以下代码

_CrtMemState memState1;
_CrtMemCheckpoint(&memState1);

char *p = new char[100];
p = new char[100];
p = new char[100];
p = new char[100];
p = new char[100];

_CrtMemState memState2;
_CrtMemCheckpoint(&memState2);
_CrtMemState memStateDiff;
_CrtMemDifference(&memStateDiff, &memState1, &memState2);
_CrtMemDumpStatistics(&memStateDiff);'

给我输出

0 bytes in 0 Free Blocks.
0 bytes in 0 Normal Blocks.
0 bytes in 0 CRT Blocks.
0 bytes in 0 Ignore Blocks.
0 bytes in 0 Client Blocks.
Largest number used: 0 bytes.
Total allocations: 0 bytes.

我在 Windows 7 Ultimate 上使用 Visual Studio 2010 Professional。

【问题讨论】:

  • 没有帖子完全符合您的要求?有什么远近的吗?内存管理内部是非常特定于供应商的,因此您不会得到一个罐头的作品-on-windows-and-linux 答案。
  • 你真的在为调试模式编译吗?您需要定义 _CRTDBG_MAP_ALLOC 并重新构建,否则您没有使用生成统计信息的 malloc/free。

标签: c++ windows linux memory-profiling checkpoint


【解决方案1】:

基于检查点的内存使用内置于 Visual C++ 中的调试 CRT 库中。

http://msdn.microsoft.com/en-us/library/974tc9t1(v=vs.80).aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-27
    • 1970-01-01
    • 1970-01-01
    • 2011-12-04
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 2011-12-07
    相关资源
    最近更新 更多