Pocket PC memory leak! help!
$30-5000 USD
Paguhet në dorëzim
Hi,
I'm having a tricky problem that may be a newbie error (I'm very new on Pocket PC).
I'm programming a very simple sprite engine, and the function I am using to actually draw the bitmap seems to be slowly leaking memory. When it draw the sprites for a few minutes the framerate starts slowing and eventually the application crashes.
I've attached the suspect code below. When I REM this code out, the application doesn't leak, at least in an hour or two of running.
Anything obvious that would clearly cause a leak or problem?
I'm using EVC++, GAPI. Targeting Pocket PC ARM, testing on a PPC 2003.
Thanks
---------------------------------------
//FUNCTION: HostDrawBitmap
//DESCRIPTION: draws bitmap to (x,y) coordinates
//PARAMETERS: resource ID of the bitmap, the x coordinate, the y coordinate (the bitmap will be drawn with x & y as top left hand corner)
---
void HostDrawBitmap(int bmID, int x, int y)
{
HBITMAP hBitmapHostDraw;
BITMAP bmBitmapHostDraw;
HDC hdcBitmapHostDraw;
HWND hWnd;
HDC hdc;
LPCWSTR bmName;
hWnd = FindWindow(NULL, NULL); //is there a safer way to get the hWnd of my application?
hdc = GetDC(NULL); //get handle to DC of current window
bmName = MAKEINTRESOURCE(bmID);
//- load and initialize variables dealing with passed in bitmap
hBitmapHostDraw = LoadBitmap(Game->GetInstance(), MAKEINTRESOURCE(bmName));
hdcBitmapHostDraw = CreateCompatibleDC(hdc);
SelectObject(hdcBitmapHostDraw, hBitmapHostDraw);
GetObject(hBitmapHostDraw, sizeof(BITMAP), &bmBitmapHostDraw);
//- use BitBlt to draw the bitmap to the screen
BitBlt(hdc, x, y, [url removed, login to view], [url removed, login to view], hdcBitmapHostDraw, 0, 0, SRCCOPY);
DeleteObject(hBitmapHostDraw); //try to clean everything
DeleteDC(hdcBitmapHostDraw); //but we still seem to have a leak somewhere!
ReleaseDC(hWnd, hdc); //could we be failing to release the DC because our hWnd is erroneous?
return;
}
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
## Platform
EVC++ 3.0
Pocket PC 2000, 2003
GAPI
ID Projekti: #3271599