VB Multiline Text Box Memory Not Freed when Form Is Unloaded

ID Number: Q79115

1.00

WINDOWS

buglist1.00

Summary:

Repeatedly loading and unloading a multiline text box in a Microsoft

Visual Basic program will result in a loss of memory proportional to

the amount of text in the text box for each unload. This memory is not

recovered until you terminate the Visual Basic environment (if running

under the VB.EXE environment), or end your compiled program (if

running a compiled .EXE). With large amounts of text or many

iterations of loading and unloading, an "Out of Memory" error can

occur.

This problem only occurs when the form is loaded and then unloaded.

Hiding a form containing a multiline text box will not result in a

loss of memory. This problem does not occur with a single line text

box.

Microsoft has confirmed this to be a problem with Microsoft Visual

Basic programming system version 1.0 for Windows. We are researching

this problem and will post new information here as it becomes

available.

More Information:

Steps to Reproduce Problem

--------------------------

1. Start Visual Basic or from the File menu, choose New Project.

2. From the File menu, choose New Form to add a second form to the

project.

3. Create a text box named "Text1" on Form2. Set the Text1 MultiLine

property to True.

4. Add the following code to Form1:

Sub Form_Click

Form2.Show

End Sub

5. Add the following code to Form2:

Sub Form_Load

Open "<any text file>" For Input As #1

While Not Eof(1)

Input #1, a$

b$ = b$ + Chr$(13) + Chr$(10) + a$

Wend

Close

Text1.Text = b$

End Sub

Sub Form_Click

Unload Form2

End Sub

6. Run the program. In the Windows Program Manager, from the Help

menu, choose About Program Manager to check free memory.

7. Click Form1; Form2 will load and display the text from the text

file.

8. Click Form2 to unload Form2; focus should return to Form1. Go to

Program Manager and check free memory again - the result is a loss

of memory proportional to the amount of text in the multiline text

box.

Showing and unloading Form2 will continue to use memory each time it

is performed. The lost memory is not recovered until you completely

exit VB.EXE or terminate your compiled Visual Basic application. This

problem does not occur when using a single line text box.

Additional reference words: 1.00