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
The local network Ip address obtained by mfc has a memory overflow last time. I 'd like to explain the solution!
Method: _ CrtSetBreakAlloc (563); // it is best to add the memory overflow row number before your memory allocation;
Shortcut Key: shift + F11 debugging. Find your memory overflow location and modify it!
The following is an example of my code: (my main problem is that the conversion function cstring to char is used, and the memory is allocated, and no delete [] is performed.)
_CrtSetBreakAlloc(556);m_devIpShow.DeleteAllItems();hThread = (HANDLE)_beginthreadex(NULL, 0, &SecondThreadFunc, NULL, 0, NULL);WaitForSingleObject( hThread, INFINITE ); CloseHandle(hThread);</span>
Jump
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;}
Jump
void* __cdecl operator new[](size_t nSize){return ::operator new(nSize);}void __cdecl operator delete[](void* p){::operator delete(p);}
Jump
// ------------------ Convert cstring to 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>
You can declare a global variable and delete it after use. You can also pass parameters to the address space in the creation thread! (When you jump to your own code, you can do it! The problem is found)