【发布时间】: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