http://www.metrowerks.com">
BUG: Memory Leaks When Using Bitmaps in Visual C++ Macintosh 4.0b 68K ApplicationsID: Q199540
|
When selecting a bitmap into a device context, SelectObject may return NULL.
When a bitmap is deleted, the memory allocated for it is not released from the application heap space. This problem occurs only for bitmaps that are not read-only (see SetBitmapReadOnly) and only with 68K applications developed using Visual C++ for Macintosh 4.0b.
Following are five different resolutions:
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.
When a bitmap is created and selected into a device context on the Macintosh using the Windows Portability Library (WPL), a new GWorld object is created (if needed) and stored in a cache of four GWorlds. This cache is also used when deleting bitmap objects. Unfortunately the cache is filled but never automatically cleared. Additionally QuickDraw allocates memory for each GWorld, which is also not released.
One workaround involves clearing the cache (which also clears the QuickDraw overhead information) using _FreeGWorldCache(). When using this function manually, enter the function prototype:
void _FreeGWorldCache(void);
Sometimes the problem can be reduced by using CreateBitmapIndirect() instead of CreateBitmap() when creating the bitmap.
http://www.metrowerks.com
(c) Microsoft Corporation 1999, All Rights Reserved. Contributions by Adam Kim, Microsoft Corporation.
Additional query words: DeleteObject Bitmap SelectObject leak CreateBitmap CreateBitmapIndirect
Keywords : kbgraphic kbMAC kbVC kbVC400bug kbDSupport MacPrgIss
Version : MACINTOSH:4.0b
Platform : MACINTOSH
Issue type : kbbug
Last Reviewed: June 23, 1999