BUG: Setting Text/Caption Property Leaks Memory on Windows CE |
Q198090
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:
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 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.
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 Additional query words: vbce
Keywords : kbToolkit kbVBp kbVBp500bug kbOSWinCEsearch kbGrpDSVB
Issue type : kbbug
Technology : kbVBSearch kbAudDeveloper kbWinCETKVBSearch kbWinCESearch kbWinCETK100VB500
|
Last Reviewed: January 8, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |