FIX: Memory Leak Occurs After Form is Unloaded (174289)
The information in this article applies to:
- Microsoft Visual Basic Control Creation Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
This article was previously published under Q174289 SYMPTOMS
A memory leak occurs in a Visual Basic project that has forms that
are loaded and unloaded several times.
CAUSE
The small icon of a form remains in memory after the form is
unloaded, which results in a memory leak.
RESOLUTION
To work around this bug in Visual Basic 4.0, use the DestroyIcon
function during the Form_Unload event to remove the small icon
from memory. Copy the following code sample to the code window of
each form in your project:
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Long) As Long
Private Declare Function DestroyIcon Lib "user32" _
(ByVal hIcon As Long) As Long
Private Const WM_SETICON = &H80
Private Const MiniIcon = 0
Private Const NullIcon = 0
Private Sub Form_Unload(Cancel As Integer)
Dim hIcon As Long
hIcon = SendMessage(hwnd, WM_SETICON, MiniIcon, ByVal _
NullIcon)
If hIcon <> 0 Then
DestroyIcon hIcon
End If
End Sub
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products
listed at the beginning of this article. This bug has been fixed
in Visual Basic Version 5.0.
Modification Type: | Minor | Last Reviewed: | 7/15/2004 |
---|
Keywords: | kb32bitOnly kbbug kbfix KB174289 |
---|
|