GDI clean up problem
- From: sreddyin123@xxxxxxxxxxx
- Date: 23 May 2006 10:30:44 -0700
Hi
I am working on WinCe project In which i am loading number of bitmap
objects using BitBlt
function
As per my understanding BitBlt allocates a memory block in the gwes
process heap.
Now my problem is I want to free the memory allocated in the gwes heap
when i dont require the bitmap anymore.
Please can u let me know any method by which i can free this memory and
reuse it again for different bitmap as my memory requirement is very
critical.
Here is the code what I am using to load a bitmap image.
CDC *pDC=this->GetDC();
CBitmap bmp;
CBrush brush;
BITMAP bitmpStruct;
CRect r;
1)HBITMAP bgBMP = LoadBitmap(AfxGetInstanceHandle(),
MAKEINTRESOURCE(m_iBkgBmpRes);
2)if(bgBMP)
{
bmp.Attach(bgBMP);
brush.CreatePatternBrush(&bmp);
GetClientRect(&r);
CBrush *pOldBrush=pDC->SelectObject(&brush);
pDC->FillRect(&r, &brush);
pDC->SelectObject(pOldBrush);
DeleteObject(bmp.Detach());
brush.DeleteObject();
}
ReleaseDC(pDC);
As per my understanding I am properly creating and destroying the GDI
objects.
When I create a brush using CreatePatternBrush The memory allocated is
twice the size of the loaded image( say IMAGE 1)
for eg In my case the image size is 152 k hence the memory allocated is
304 k.
and when i delete the brush object It only recovers 152 k while the
other 152 k is not recovered.
When I load a new bitmap image I face the same problem
Now when I load the same image IMAGE 1 then the CreatePatternBrush
allocates just 152 k and frees it when i call deleteobject.which is
true for every loaded image.
But i am not able to recover the memory leaked while loading every new
image.
As per my Application is fully graphical and the memory requirement are
very critical
I want to able to retrieve the memory allocated by bitmaps which are
not required.which I am not able to do.
I then tried to load the image using BitBlt which is showing me the
same type of problem that is the memory is not recovered.
I read somewhere that GDI takes some time to clean up the unused
memory.Is it that which is causing this leak.
Please let me know what I can do solve this problem.
Shankar
.
- Prev by Date: Printing positive from 2000 but negative from XP
- Next by Date: Re: Problem with multiple bootable devices
- Previous by thread: Printing positive from 2000 but negative from XP
- Next by thread: How come NDISPROT simply compiles to 32 bit or 64 bit ?
- Index(es):
Relevant Pages
|