Microsoft KB Archive/223103

From BetaArchive Wiki

Article ID: 223103

Article Last Modified on 5/12/2003



APPLIES TO

  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 6.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
  • Microsoft Visual Basic 6.0 Enterprise Edition



This article was previously published under Q223103

SYMPTOMS

A memory leak might occur on Japanese Windows 95C (OSR 2.5) when unloading a Form that contains a CommandButton.

CAUSE

This problem occurs when the CommandButton's TabIndex property = "0" and its TabStop property = "TRUE."

RESOLUTION

Set the TabIndex of the CommandButton to a value greater than 0.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed

MORE INFORMATION

Steps to Reproduce Behavior

  1. Start a new Visual Basic Standard EXE Project. Form1 is created by default.
  2. Add a CommandButton and Timer control to Form1.
  3. Add the following code to the General Declarations section of Form1:

    Option Explicit
    Private f As Boolean
    
    Private Sub Command1_Click()
       Timer1.Enabled = True
    End Sub
    
    Private Sub Form_Load()
       Timer1.Interval = 500
       Timer1.Enabled = False
    End Sub
    
    Private Sub Timer1_Timer()
       f = Not f
       If f Then
          Form2.Show
       Else
          Unload Form2
          Set Form2 = Nothing
       End If
    End Sub
                        
  4. On the Project menu, click Add Form to add a new form to the project. Form2 is created by default.
  5. Add a CommandButton to Form2.
  6. Compile the Application to an EXE file.
  7. Run the compiled EXE on Japanese Windows 95C.
  8. Start the System Monitor tool, which is located in the System Tools folder in the Accessories folder. (If the System Monitor tool is not available, it can be installed from the Control Panel Add/Remove Programs option.) On the Edit menu, click Add Item. Click the Memory Manager Category, click the Allocated Memory Item, and click OK.
  9. Click Command1 to start loading/unloading Form2.

    Result: The "Allocated Memory" will steadily increase as the application is running and might eventually cause the application to crash.


Keywords: kbbug kbfix kbintl kbintldev kbvs600sp3fix KB223103