我正在开发一个基于网络的应用程序。我想查看应用程序不同阶段之间的内存使用情况,例如初始化和释放之间的内存使用情况或发送和接收之间的内存使用情况。我用谷歌搜索并尝试找到解决方案,但没有完全符合我的要求的帖子。
请大家推荐任何可以帮助我在 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。
最佳答案
基于检查点的内存使用情况内置于 Visual C++ 中的调试 CRT 库中。
http://msdn.microsoft.com/en-us/library/974tc9t1(v=vs.80).aspx
关于c++ - 是否有任何工具支持 C++ 基于检查点的内存使用分析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12404134/