📄 subject_24019.htm
字号:
<p>
序号:24019 发表者:xiongli 发表日期:2002-12-08 21:58:02
<br>主题:几个才遇上的c/c++问题,关于内存泄漏的检测和__try
<br>内容:#define _CRTDBG_MAP_ALLOC<BR>#include <stdlib.h><BR>#include <crtdbg.h><BR>#include <iostream><BR>#include <vector><BR>#include <algorithm><BR>using namespace std;<BR><BR>int k(void (*d)())<BR>{<BR> d();<BR> return 0;<BR>}<BR>void j(void (*d)())<BR>{<BR> d();<BR>}<BR>void test()<BR>{<BR> cout <<0;<BR>}<BR>int main()<BR>{<BR>// int *jkm=(int*)malloc(sizeof(int));<BR>/* void (*p)(void (*)());<BR> p=j;<BR> j(test);<BR> int (*pp)(void (*)());<BR> pp=k;<BR> p(test);*/<BR> _CrtDumpMemoryLeaks();<BR> return 0;<BR>}<BR><BR>以上是一段随便写的代码,按照msdn,这样可以dump出malloc造成的memory leak.但是我再main里面直接return,debug里面居然显示<BR><BR>Loaded 'C:\WINNT\System32\ntdll.dll', no matching symbolic information found.<BR>Loaded 'C:\WINNT\system32\KERNEL32.DLL', no matching symbolic information found.<BR>Detected memory leaks!<BR>Dumping objects -><BR>c:\program files\microsoft visual studio\vc98\include\crtdbg.h(552) : {62} normal block at 0x004815A0, 33 bytes long.<BR> Data: < C > 00 43 00 CD CD CD CD CD CD CD CD CD CD CD CD CD <BR>c:\program files\microsoft visual studio\vc98\include\crtdbg.h(552) : {61} normal block at 0x004815F0, 40 bytes long.<BR> Data: <t F > 74 B2 46 00 16 00 00 00 00 00 00 00 00 00 00 00 <BR>Object dump complete.<BR>The thread 0x514 has exited with code 0 (0x0).<BR>The program 'C:\Documents and Settings\Administrator\桌面\subject_1_19199\Debug\node_lev.exe' has exited with code 0 (0x0).<BR><BR><BR>说有内存泄漏.这是第一个不解<BR>同时我想问,在c++/vc++里面如何检查new造成的内存泄漏.我在msdn上看到一些方法,比如用<BR>CMemoryState<BR>但是我记得我以前看到过一种简单dump的方法,也是前面include,然后好像要define new __new的.能给一个例子吗??<BR><BR>第三个问题.常常看到一些关键字前面有__.比如__int 32 __try __catch等等.我想问一下,这代表什么??<BR>谢谢
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:混混 回复日期:2002-12-08 22:16:14
<br>内容:这部分提示就是dump出的泄漏(没有free)<BR>c:\program files\microsoft visual studio\vc98\include\crtdbg.h(552) : {62} normal block at 0x004815A0, 33 bytes long.<BR>Data: < C > 00 43 00 CD CD CD CD CD CD CD CD CD CD CD CD CD <BR>c:\program files\microsoft visual studio\vc98\include\crtdbg.h(552) : {61} normal block at 0x004815F0, 40 bytes long.<BR>Data: <t F > 74 B2 46 00 16 00 00 00 00 00 00 00 00 00 00 00 <BR><BR>CMemoryState 我不知道,<BR><BR>加__好像是在支持标准c++的同时,搞点微软的特色<BR><BR>2002-12-8 22:18:37
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -