我正在研究一个基于networking的应用程序。 我想看看我的应用程序的不同阶段之间的内存使用情况,如初始化和释放之间的内存使用情况或发送和接收之间的内存使用情况。 我GOOGLE了,并试图find一个解决scheme,但没有发布完全符合我的要求。
请大家提一下可以帮助我在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旗舰版上的Visual Studio 2010专业版。
基于检查点的内存使用情况内置于Visual C ++中的调试CRT库中。
http://msdn.microsoft.com/en-us/library/974tc9t1(v=vs.80).aspx