Detected memory leaks! Dumping objects, leaksdumping

Source: Internet
Author: 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 

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)



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.