????C++?????????????????????????????????г?????????????????κ??????????????????????????????????????????????????New??malloc??realloc????????棬??????????????????Delete??free??????C++???й??????????????????????????????????????????????????к???????????????Windows??????????????????????????????????????????????????????????????????????й???????е????????????????????????й????????STL??????????Smart Point????????Java???????????????????C++??Smart Pointer??????????????????????????????????????????????VC????C++???й??????????????????й????????????ζ?????????????????????????ο??????
????1?????????????C++ ??CRT???????????????Debug????????CRT???????????????????
????#define _CRTDBG_MAP_ALLOC
????#include <stdlib.h>
????#include <crtdbg.h>
????????????????????????
????2??????????????????й??????????????
????_CrtDumpMemoryLeaks();
?????????MFC??????????????е????????
????Detected memory leaks!
????Dumping objects ->
????d:/program files/microsoft visual studio .net 2003/vc7/include/crtdbg.h(689) : {54} normal block at 0x00371078?? 4 bytes long.
????Data: <  D > 94 20 44 00
????d:/program files/microsoft visual studio .net 2003/vc7/include/crtdbg.h(689) : {53} normal block at 0x00371038?? 4 bytes long.
????Data: <  D > BC 20 44 00
????Object dump complete.
????????????????λ?????й???????????λ?á?
????3????ν????t???й???λ???
????#ifdef _DEBUG
????#define new   new(_NORMAL_BLOCK??__FILE__?? __LINE__)
????#endif
???????н?????£?
????Detected memory leaks!
????Dumping objects ->
????f:/testvc/factory/factory.cpp(93) : {54} normal block at 0x00371078?? 4 bytes long.
????Data: <  D > 94 20 44 00
????f:/testvc/factory/factory.cpp(102) : {53} normal block at 0x00371038?? 4 bytes long.
????Data: <  D > BC 20 44 00
????Object dump complete.
????4????θ???????????й???
????????????????????е??{54}??{53}????????????????????????_CrtSetBreakAlloc(53)??_CrtSetBreakAlloc(54)?????????????????й??????????λ?á?
????CRT???к????????????????????????????????????????????????????