CImage img;
HRESULT ret = img.Load(strpathname ); // filename 是要加载的文件名(包含路径) HBITMAP hbm = img.Detach();
CBitmap bmp;
BITMAP bm;
bmp.Attach(hbm);
bmp.GetBitmap(&bm);
HDC hMemDC=CreateCompatibleDC(pDC->m_hDC);
SelectObject(hMemDC,hbm);
CRect rc;
GetClientRect(rc);
StretchBlt(pDC->m_hDC,0,0,rc.Width(),rc.Height(),hMemDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
bmp.DeleteObject();
Invalidate();
上面这段代码加载图片时内存泄露,程序所占内存增不减,我不清楚问题出在哪,请问如何修改?
HRESULT ret = img.Load(strpathname ); // filename 是要加载的文件名(包含路径) HBITMAP hbm = img.Detach();
CBitmap bmp;
BITMAP bm;
bmp.Attach(hbm);
bmp.GetBitmap(&bm);
HDC hMemDC=CreateCompatibleDC(pDC->m_hDC);
SelectObject(hMemDC,hbm);
CRect rc;
GetClientRect(rc);
StretchBlt(pDC->m_hDC,0,0,rc.Width(),rc.Height(),hMemDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
bmp.DeleteObject();
Invalidate();
上面这段代码加载图片时内存泄露,程序所占内存增不减,我不清楚问题出在哪,请问如何修改?
另外找个GDI查看器,看看什么在不停的增长,就知道了
bmp.deleteobject
dc.deleteobject
SelectObject(hMemDC,hbm);
DeleteDC(hMemDC);
内存是不在增长了,但查看任务管理器的时候发现CPU占用一直是50,原来不加的时候也是这样,请问哪里还有问题导致CPU占用这么高?