BUG: OLE DataText Prop Doesn't Free Memory When Object Closed

Last reviewed: June 21, 1995
Article ID: Q97136
The information in this article applies to:

- The Professional Edition of Microsoft Visual Basic for Windows,

  version 2.0

SYMPTOMS

An OLE destination (OLE client) control (OLECLIEN.VBX) can send data to the OLE source (OLE server) application by setting the DataText property, however the memory allocated for this data is not released until OLECLIEN.VBX is unloaded. The memory is freed when you exit from the application.

STATUS

Microsoft has confirmed this to be a bug in the Professional Edition of Microsoft Visual Basic version 2.0 for Windows. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Each time an OLE destination object is created and the DataText property is set, a new private segment is allocated by OLECLIEN.VBX. When working in the VB.EXE interpreter environment, this segment is deallocated when you exit from VB.EXE or when you start a new project (ALT+F+N). A Visual Basic EXE program deallocates this segment when it is unloaded.

The following code uses Microsoft Graph as the OLE source application, but the memory leak also occurs if OLECLIEN.VBX is used with other OLE source programs.

To verify that the memory leak occurs, run the code listed below. Then load a tool like Heap Walker that ships with the Microsoft Windows Software Development Kit (SDK), and watch the number of private segments allocated to OLECLIENT change even after the code deletes the OLE objects.

Steps to Reproduce Problem

  1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.

  2. From the File menu, choose Add File. In the Files box, select the OLECLIEN.VBX custom control file. The OLE destination (client) tool appears in the Toolbox.

  3. Place an OLEClient control on Form1.

  4. Enter the following code:

       Private Sub Form_Click ()
          Const OLE_CREATE_NEW = 0
          Const OLE_UPDATE = 6
          Const OLE_ACTIVATE = 7
          Const OLE_CLOSE = 9
          Const OLE_DELETE = 10
    
          OleClient1.Class = "MSGraph"
          OleClient1.Protocol = "StdFileEditing"
          OleClient1.ServerType = 1
          OleClient1.Action = OLE_CREATE_NEW
          OleClient1.Action = OLE_ACTIVATE
          OleClient1.Format = "CF_TEXT"   ' MS Graph accepted format
    
          Title$ = "This is a title" & Chr$(10)
    
          ' The data for a graph
          Dim Tb As String  ' tab character
          Tb = Chr$(9)
          GraphData$ = "A" & Tb & "3" & Tb & "4" & Tb & "5" & Chr$(10)
          GraphData2$ = "B" & Tb & "9" & Tb & "2" & Tb & "4" & Chr$(10)
    
          ' Cause a private segment in OLECLIEN to be allocated.
          OleClient1.DataText = Title$ & GraphData$ & GraphData2$
    
          OleClient1.Action = OLE_UPDATE
          OleClient1.Action = OLE_CLOSE
          OleClient1.Action = OLE_DELETE
       End Sub
    
    

  5. From the Run menu, choose Start.

  6. Run a utility such as Heap Walker to list the number of segments allocated to OLEClient.

  7. Click the form to create and delete an OLE object from Microsoft Graph.

At this point, you'll see that the number of private segments allocated to OLEClient increases by 1.


Additional reference words: buglist2.00 2.00 MemLeak
KBCategory: kbole kbprg kbbuglist
KBSubcategory: IAPOLE


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.