Microsoft KB Archive/192050

= BUG: Resource Leak with 256 Color Bitmap/UseZOrder PaletteMode =

Article ID: 192050

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q192050



SYMPTOMS
You may see a loss of System and GDI resources when repeatedly loading a picture if the Form's PaletteMode is set to UseZOrder and the Windows system display color settings are set to 256 colors. Because of the differences in the way that Windows 95/98 and Window NT manage memory, the consequences of this problem may be more apparent on a computer running Windows 95/98 than on a computer running Windows NT/2000.



RESOLUTION
Set the PaletteMode property of the form to a setting other than UseZOrder.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
These steps require that you have a 256 color bitmap. If you have a bitmap you would like to use, substitute it for "C:\test.bmp" in step 5. If not, create a 2 x 2 inch bitmap using Paint or other software capable of creating a bitmap.

 On a machine running Windows 95/98, set the Windows display system color setting to 256 colors. Start a new Standard EXE project in Visual Basic. Form1 is created by default. Add a CommandButton and an Image control to Form1. Set the PaletteMode property of Form1 to UseZOrder.  Add the following code to the module of Form1: Private Sub Command1_Click Dim b As Boolean Dim i As Integer

For i = 1 To 500 Caption = Str(i) b = Not b        If b Then Image1.Picture = LoadPicture("c:\test.bmp") Else Image1.Picture = LoadPicture("") End If     Next i      End Sub

 From the File menu, choose Make Project1.exe.</li> Save the project and close Visual Basic.</li> Start the Windows Resource Meter, and display the Resource Meter window by right-clicking on the icon in the TaskBar, and selecting Details.</li> Run Project1.exe and click on the CommandButton. You should see the System and GDI resources decreasing. These resources are not reclaimed until you exit Project1.exe.</li></ol>

Keywords: kbbug kbbitmap kbpending KB192050

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.