GDI leakage and Memory leakage detection methods

Source: Internet
Author: User

GDI leak detection method:

1. Check whether getwindowdc () and releasedc () exist ()

2. cfont * poldfont = PDC-> SelectObject (& m_font );

Whether there is PDC-> SelectObject (poldfont );

3. cbitmap BMP;
BMP. createcompatiblebitmap (& DC, rcclient. Width (), rcclient. Height ());

Do you remember BMP. deleteobject ();

 

Memory leakage detection method

1. Check new, virtualalloc,HeapAlloc,malloc Is it not released?

2. _ crtmemstate S1, S2, S3;
_ Crtmemcheckpoint (& S1 );
// Memory allocations take place here
_ Crtmemcheckpoint (& S2 );
  
If (_ crtmemdifference (& S3, & S1, & S2 ))
_ Crtmemdumpstatistics (& S3 );

 

Cmemorystate msold;

Msold. Checkpoint ();

 

Msold. dumpallobjectssince ();

 

3. _ crtsetbreakalloc (18 );

4. boundschecker Tool

5. F:/RTM/vctools/vc7libs/ship/atlmfc/src/mfc/strcore. cpp (141)
If the above output is displayed, use _ crtdumpmemoryleaks (); for debugging.

F:/sourcesafe fold/mccsclient/mccsclientdlg. cpp (1863): {63669} normal block at 0x02f21278, 8 bytes long.
Data: <x> E8 CC F1 02 F0 78 F1 02

 

Generally, this problem is caused by cstring. simply change it to the char pointer type.

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.