Detected memory leaks! Dumping objects,leaksdumping

來源:互聯網
上載者:User

Detected memory leaks! Dumping objects,leaksdumping

Detected memory leaks!Dumping objects ->{563} normal block at 0x0FAF4D60, 255 bytes long. Data: <SD-20140120MYGT > 53 44 2D 32 30 31 34 30 31 32 30 4D 59 47 54 00 

mfc 擷取區域網路Ip上次有記憶體溢出,我來說說解決辦法!


方法:_CrtSetBreakAlloc(563); // 最好在你記憶體配置的前面加上記憶體溢出的行號;

快速鍵:shift+F11 進行調試找到你記憶體溢出的位置進行修改即可!

下面就以我代碼例子如下:(我的主要問題在於,使用了cstring 轉 char 的轉換函式,記憶體配置了,並未進行 delete [])

_CrtSetBreakAlloc(556);m_devIpShow.DeleteAllItems();hThread = (HANDLE)_beginthreadex(NULL, 0, &SecondThreadFunc, NULL, 0, NULL);WaitForSingleObject( hThread, INFINITE );  CloseHandle(hThread);</span>

跳轉

extern "C" _CRTIMP void * __cdecl _malloc_dbg (        size_t nSize,        int nBlockUse,        const char * szFileName,        int nLine        ){        void *res = _nh_malloc_dbg(nSize, _newmode, nBlockUse, szFileName, nLine);        RTCCALLBACK(_RTC_Allocate_hook, (res, nSize, 0));        return res;}

跳轉

void* __cdecl operator new[](size_t nSize){return ::operator new(nSize);}void __cdecl operator delete[](void* p){::operator delete(p);}

跳轉

//------------------cstring 轉 string 

char* zhuanhuan(std::string src) {char *dst = new char[255];int i; int j=src.length();for(i=0;i <src.length();i++) dst[i]=src[i]; dst[i] = '\0';return dst;}</span>

可以聲明一個全域的變數,使用以後進行delete 得已解決也可以在建立線程,把地址空間傳參數!(當跳轉到你自己寫的代碼,就行了哈!說明找到問題了)



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.