????????????????????????? ??????????????£? ??????????

#ifdef _DEBUG
#define DEBUG_CLIENTBLOCK   new( _CLIENT_BLOCK?? __FILE__?? __LINE__)
#else
#define DEBUG_CLIENTBLOCK
#endif
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#ifdef _DEBUG
#define new DEBUG_CLIENTBLOCK
#endif


int _tmain(int argc?? _TCHAR* argv[])
{
    char* p = new char();
    char* pp = new char[10];
    char* ppp = (char*)malloc(10);

    _CrtDumpMemoryLeaks();

    return 0;
}

????????????????Crt ????????????????????????operator new????????????汾?????

void *__CRTDECL operator new(
        size_t cb??
        int nBlockUse??
        const char * szFileName??
        int nLine
        )
        _THROW1(_STD bad_alloc)
{
    /* _nh_malloc_dbg already calls _heap_alloc_dbg in a loop and calls _callnewh
       if the allocation fails. If _callnewh returns (very likely because no
       new handlers have been installed by the user)?? _nh_malloc_dbg returns NULL.
     */
    void *res = _nh_malloc_dbg( cb?? 1?? nBlockUse?? szFileName?? nLine );

    RTCCALLBACK(_RTC_Allocate_hook?? (res?? cb?? 0));

    /* if the allocation fails?? we throw std::bad_alloc */
    if (res == 0)
    {
        static const std::bad_alloc nomem;
        _RAISE(nomem);
    }

    return res;
}

????????Crt????η???????????????к??????С??????????????????_CrtDumpMemoryLeaks()?????????????????????

??????????£?

Detected memory leaks!
Dumping objects ->
f: estmemleakcheckermemleakcheckermemleakchecker.cpp(23) : {108} normal block at 0x0003A1A8?? 10 bytes long.
 Data: <          > CD CD CD CD CD CD CD CD CD CD
f: estmemleakcheckermemleakcheckermemleakchecker.cpp(22) : {107} client block at 0x0003A160?? subtype 0?? 10 bytes long.
 Data: <          > CD CD CD CD CD CD CD CD CD CD
f: estmemleakcheckermemleakcheckermemleakchecker.cpp(21) : {106} client block at 0x0003A120?? subtype 0?? 1 bytes long.
 Data: < > 00
Object dump complete.