BUG: Setting Text/Caption Property Leaks Memory on Windows CE
ID: Q198090
|
The information in this article applies to:
-
Microsoft Windows CE Toolkit for Visual Basic 5.0, version 1.0
SYMPTOMS
The amount of available program memory decreases when repeatedly setting
text or caption properties of intrinsic controls.
RESOLUTION
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:
- Create a new Windows CE Project in Visual Basic. Form1 is created by
default.
- In the Project Properties dialog box, make sure that "Run on Target" is
set to Remote Device.
- Place a command button on Form1.
- 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
- Run the project.
- On the H/PC device, go to the Control Panel and launch the System
applet. Select the Memory tab.
- 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.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
MORE INFORMATION
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.
Steps to Reproduce Behavior
- Create a new Windows CE Project in Visual Basic. Form1 is created by
default.
- In the Project Properties dialog box, make sure that "Run on Target" is
set to Remote Device.
- Place a command utton and a label on Form1.
- 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
- Run the project.
- On the H/PC device, go to the Control Panel and launch the System
applet. Select the Memory tab.
- 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 kbGrpVB
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbbug