ID: Q198090
The information in this article applies to:
The amount of available program memory decreases when repeatedly setting text or caption properties of intrinsic controls.
There are a couple of potential workarounds for this behavior. Most straightforward is to minimize the frequency of changing text or caption properties of controls.
Secondly, painting the desired text directly onto the form or control as opposed to setting the text or caption property also works around this behavior. For example:
1. Create a new Windows CE Project in Visual Basic. Form1 is created by
default.
2. In the Project Properties dialog box, make sure that "Run on Target" is
set to Remote Device.
3. Place a command button on Form1.
4. Add the following code into the code module for Form1:
Option Explicit
Dim NewLabelCaption
Private Sub Form_Load()
ScaleMode = vbPixels
Command1.Caption = "Update"
End Sub
Private Sub Command1_Click()
NewLabelCaption = FormatDateTime(Now)
DrawLabels
End Sub
Public Sub DrawLabels()
Cls
' Label1
CurrentX = 10
CurrentY = 25
Print NewLabelCaption
' Label2
CurrentX = 10
CurrentY = 50
Print NewLabelCaption
' Label3
CurrentX = 10
CurrentY = 75
Print NewLabelCaption
End Sub
5. Run the project.
6. On the H/PC device, go to the Control Panel and launch the System
applet. Select the Memory tab.
7. In the Visual Basic CE project, click the command button repeatedly.
Notice that the Program Memory "In Use" does not increase each time the command button is clicked.
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
This problem exists for all controls that have a Text or Caption property. The amount of memory leaked is the same as the size of the string assigned to the property.
1. Create a new Windows CE Project in Visual Basic. Form1 is created by
default.
2. In the Project Properties dialog box, make sure that "Run on Target" is
set to Remote Device.
3. Place a command utton and a label on Form1.
4. Add the following code into the code module for Form1:
Option Explicit
Dim MyString
Private Sub Command1_Click()
Label1.Caption = MyString
End Sub
Private Sub Form_Load()
Dim lLoop
'Load the string with 10k of data
For lLoop = 0 To 10000
MyString = MyString & "x"
Next
End Sub
5. Run the project.
6. On the H/PC device, go to the Control Panel and launch the System
applet. Select the Memory tab.
7. In the Visual Basic CE project, click the command button repeatedly.
Notice that the Program Memory "In Use" increases each time the command button is clicked.
Additional query words: vbce
Keywords : kbToolkit kbVBp kbVBp500bug kbWinCE
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbpending
Last Reviewed: December 31, 1998