Cximage memory Leaks _ memory leaks

Source: Internet
Author: User

It seems that there is no introduction to the Cximage Library memory leak, if you apply it to the development of the actual project, it will be a big hole.

I wrote the test program interface as follows:


--------------------------------------------------------------------------------------------------------------- -------------

By opening a thread, I continue to keep the image of the operation, and found that the program runs about 30 minutes,

The memory leak is obvious, and the key code is as follows:

void Ctestcximagedlg::onbnclickedbutton1 ()
{
	//TODO: Add control notification handler code here
	GetDlgItem (idc_button1)-> EnableWindow (FALSE);
	GetDlgItem (Idc_button2)->enablewindow (TRUE);

	M_isrun=true;
	_beginthreadex (Null,0,threadtestproxy,this,0,null);
}


void Ctestcximagedlg::onbnclickedbutton2 ()
{
	//TODO: Add control notification handler code here
	GetDlgItem (idc_button1)-> EnableWindow (TRUE);
	GetDlgItem (Idc_button2)->enablewindow (FALSE);
	M_isrun=false;
}

void Ctestcximagedlg::threadtest ()
{
	CString imgpath;
	GetDlgItemText (Idc_txt_img_path,imgpath);
	while (M_isrun)
	{
		DeleteFile ("123.jpg");
		Cximage image (Imgpath.getbuffer (), cximage_format_jpg);
		if (image. IsValid ())
		{
			image. Setjpegquality ();   JPG compression quality
			//image. Crop (0,0,m_icarheadwidthsave,m_icarheadheightsave);     Screenshot
			image. Crop (0,0,1024,768); 
			Image. Crop (rccrop);
			Image. Resample (800,600);       The resolution image of the image
			. Save ("123.jpg", cximage_format_jpg);
		}
		Image. Destroy ();
		Sleep (1000);
	}

--------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------

Do not believe the pot friend, may wish to try.

Example VS2010 Engineering Download: http://download.csdn.net/detail/friendan/7723703

--------------------------------------------------------------------------------------------------------------- -----------------------------

Your very satisfaction is my pursuit of the purpose.

A little advice from you is my motivation to follow.








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.