hDc=GetDC(hwnd);
hdcMem=CreateCompatibleDC(hDc);
hbmNew=SHLoadDIBitmap(*****);
GetObject(hbmNew, sizeof(bm), &bm);
SelectObject(hdcMem,hbmNew);
BitBlt(hDc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
12 个解决方案
#1
the internal index of system objects.
#2
HDC HBITMAP是句柄吧,前者是DC句柄,后者是位图句柄,不是地址
#3
你把系统资源用光了,而不是把内存用光了。最后加一句 ReleaseDC(hwnd, hDC);
#4
这程序是在WinCE上跑的,确实是造成内存不足了,系统提示的。我觉得HDC HBITMAP是和内存有关的,哪位给我讲讲HDC HBITMAP和内存的关系啊
#5
All the objects about GDI are maintained by operating system.
Once you created a GDI object(e.g, HBITMAP), that you have to manually release it when you ain't long time to use it, otherwise, this will cause the resource of system to be consumed as possible. of couse, the both Win2K/XP can automatically release these disabled GDI objects, but Win95/98/Me never do it.
Once you created a GDI object(e.g, HBITMAP), that you have to manually release it when you ain't long time to use it, otherwise, this will cause the resource of system to be consumed as possible. of couse, the both Win2K/XP can automatically release these disabled GDI objects, but Win95/98/Me never do it.
#6
哦,那用同一个窗口的hDc变量,做多次BitBlt,是不是每次release后都要做GetDC(hwnd)初始化工作
#7
楼主可以去补下基础知识哦。
#8
http://www.wangchao.net.cn/bbsdetail_17426.html
#9
谢谢believefym的链接
#10
具体的说吧
hDc=GetDC(hwnd);
hdcMem=CreateCompatibleDC(hDc);
while(cyclerun==1)
{
hbmNew=SHLoadDIBitmap(_T("***.bmp"));//图一
GetObject(hbmNew, sizeof(bm), &bm);
SelectObject(hdcMem,hbmNew);
BitBlt(hDc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
hbmNew=SHLoadDIBitmap(_T("***.bmp"));//图二
GetObject(hbmNew, sizeof(bm), &bm);
SelectObject(hdcMem,hbmNew);
BitBlt(hDc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
}
Release(hwnd,hDc);
Release(hwnd,hdcMem);
这段代码内存泄露是hbmNew引起的吧,和hDc hdcMem没关系吧
hDc=GetDC(hwnd);
hdcMem=CreateCompatibleDC(hDc);
while(cyclerun==1)
{
hbmNew=SHLoadDIBitmap(_T("***.bmp"));//图一
GetObject(hbmNew, sizeof(bm), &bm);
SelectObject(hdcMem,hbmNew);
BitBlt(hDc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
hbmNew=SHLoadDIBitmap(_T("***.bmp"));//图二
GetObject(hbmNew, sizeof(bm), &bm);
SelectObject(hdcMem,hbmNew);
BitBlt(hDc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
}
Release(hwnd,hDc);
Release(hwnd,hdcMem);
这段代码内存泄露是hbmNew引起的吧,和hDc hdcMem没关系吧
#11
其实我是想问问资源句柄和内存的关系,什么都照着MSDN没有深层次的思考,没意思
#12
哦,那用同一个窗口的hDc变量,做多次BitBlt,是不是每次release后都要做GetDC(hwnd)初始化工作
release 与GetDC相对应
用到多次无须每次都GetDC,一次就行...
release 与GetDC相对应
用到多次无须每次都GetDC,一次就行...
#1
the internal index of system objects.
#2
HDC HBITMAP是句柄吧,前者是DC句柄,后者是位图句柄,不是地址
#3
你把系统资源用光了,而不是把内存用光了。最后加一句 ReleaseDC(hwnd, hDC);
#4
这程序是在WinCE上跑的,确实是造成内存不足了,系统提示的。我觉得HDC HBITMAP是和内存有关的,哪位给我讲讲HDC HBITMAP和内存的关系啊
#5
All the objects about GDI are maintained by operating system.
Once you created a GDI object(e.g, HBITMAP), that you have to manually release it when you ain't long time to use it, otherwise, this will cause the resource of system to be consumed as possible. of couse, the both Win2K/XP can automatically release these disabled GDI objects, but Win95/98/Me never do it.
Once you created a GDI object(e.g, HBITMAP), that you have to manually release it when you ain't long time to use it, otherwise, this will cause the resource of system to be consumed as possible. of couse, the both Win2K/XP can automatically release these disabled GDI objects, but Win95/98/Me never do it.
#6
哦,那用同一个窗口的hDc变量,做多次BitBlt,是不是每次release后都要做GetDC(hwnd)初始化工作
#7
楼主可以去补下基础知识哦。
#8
http://www.wangchao.net.cn/bbsdetail_17426.html
#9
谢谢believefym的链接
#10
具体的说吧
hDc=GetDC(hwnd);
hdcMem=CreateCompatibleDC(hDc);
while(cyclerun==1)
{
hbmNew=SHLoadDIBitmap(_T("***.bmp"));//图一
GetObject(hbmNew, sizeof(bm), &bm);
SelectObject(hdcMem,hbmNew);
BitBlt(hDc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
hbmNew=SHLoadDIBitmap(_T("***.bmp"));//图二
GetObject(hbmNew, sizeof(bm), &bm);
SelectObject(hdcMem,hbmNew);
BitBlt(hDc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
}
Release(hwnd,hDc);
Release(hwnd,hdcMem);
这段代码内存泄露是hbmNew引起的吧,和hDc hdcMem没关系吧
hDc=GetDC(hwnd);
hdcMem=CreateCompatibleDC(hDc);
while(cyclerun==1)
{
hbmNew=SHLoadDIBitmap(_T("***.bmp"));//图一
GetObject(hbmNew, sizeof(bm), &bm);
SelectObject(hdcMem,hbmNew);
BitBlt(hDc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
hbmNew=SHLoadDIBitmap(_T("***.bmp"));//图二
GetObject(hbmNew, sizeof(bm), &bm);
SelectObject(hdcMem,hbmNew);
BitBlt(hDc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
}
Release(hwnd,hDc);
Release(hwnd,hdcMem);
这段代码内存泄露是hbmNew引起的吧,和hDc hdcMem没关系吧
#11
其实我是想问问资源句柄和内存的关系,什么都照着MSDN没有深层次的思考,没意思
#12
哦,那用同一个窗口的hDc变量,做多次BitBlt,是不是每次release后都要做GetDC(hwnd)初始化工作
release 与GetDC相对应
用到多次无须每次都GetDC,一次就行...
release 与GetDC相对应
用到多次无须每次都GetDC,一次就行...