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.