BUG: EMF Playback into DC Causes Memory Leak in GDILast reviewed: January 11, 1997Article ID: Q156696 |
The information in this article applies to:
SYMPTOMSIn Windows 95, when calling PlayEnhMetaFile() with a non-NULL clipping region selected into the DC, GDI fails to free a copy of the clipping region it creates, thereby causing a memory leak. This leaked resource is a system resource and will not be freed when the application exits.
CAUSEWhen RestoreDC() is called, it copies the hMetaRgn value in the saved block over the hMetaRgn value in the hDC. If the value in the save block is NULL and the value in the hDC is not, the only reference to that region is lost and the region is not freed. Instead, RestoreDC() should check for the above case and free the region. When PlayEnhMetaFile() is called, it calls the following functions: SaveDC(), SetMetaRgn(), play EMF records, and RestoreDC(). This creates the hMetaRgn if there is a clipping region in the hDC, and then fails to release it.
RESOLUTIONTo work around this problem, render the Enhanced Metafile (EMF) unclipped to a bitmap, and BitBlt() the image to the screen.
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
Steps to Reproduce Problem
|
KBCategory: kbprg kbbuglist
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |