DDE from Excel to VB Uses Up Windows GDI Heap

ID Number: Q80440

1.00

WINDOWS

buglist1.00

Summary:

During a dynamic data exchange (DDE) conversation between a Microsoft

Visual Basic picture control that is automatically or manually linked

to a Microsoft Excel for Windows cell range, updates to individual

cells are not deleted from memory. This problem does not occur when a

Visual Basic label control or text box is automatically or manually

linked to Excel.

When data in the Excel spreadsheet is constantly updated, resources

are consumed and not discarded; as a result, Microsoft Windows version

3.0 may eventually hang. The memory is not released when both the

Visual Basic and Excel applications are terminated, but only when

Windows 3.0 is terminated.

Microsoft has confirmed this to be a problem in Microsoft Visual Basic

programming system version 1.0 for Windows. We are researching this

problem and will post new information here as it becomes available.

More Information:

Using the Heap Walker utility provided with the Microsoft Windows

Software Development Kit (SDK), you can verify that unrecoverable

memory is being allocated during a DDE conversation between Visual

Basic and Excel. Below are the steps necessary to confirm that memory

is being lost during a DDE conversation between Visual Basic and

Excel:

Steps to Reproduce Problem

--------------------------

1. Start an Excel session.

2. Enter data into cells R1C1 through R3C3 (that is, cells A1, A2,

A3, B1, B2, B3, C1, C2, C3).

3. Select these cells.

4. Press CTRL+INS to copy the cells.

5. Start Visual Basic, or if Visual Basic is already running, choose

New Project from the File menu (ALT, F, N).

6. Add a Picture control (Picture1) to Form1.

7. From the Edit menu, choose Paste Link. A graphic image of the

Excel cell range should be displayed in Picture1.

8. From the Run menu, choose Start (ALT, R, S) to run the Visual

Basic program.

9. Run Heap Walker (a tool provided with the Windows SDK).

10. From the Sort menu, choose "Module" and "Label Segments".

11. From the Walk menu, choose GC(-1) And Walk. (This command attempts

to discard all discardable objects and then display the memory

heap.)

12. Select all segments labeled GDI by holding down the left mouse

button and dragging the mouse downward from the first GDI segment.

The window should scroll up as the segments (or lines) are

selected. Release the mouse button when the last GDI segment in

the block has been selected.

13. With all the segments highlighted, choose the Add! menu to get a

total of the segments and bytes used. Make note of these values

for comparison.

14. Activate Excel.

15. Change the values in the selected cell range of Excel a number of

times.

Note: By using repeated patterns such as filling the cells with

the value 999999, later (when using the Show submenu of the Object

menu to see the contents of a GDI segment) you can verify that a

segment is a leftover from the DDE conversation. Scrolling through

the segment, toward the end of the segment you will see the digits

you entered on the right side of the display.

16. Repeat steps 12 through 15.

17. Compare the values returned by Add!. The later value should be

significantly larger.

18. Activate Heap Walker.

19. From the Object menu, choose Show to view the heap owned by the

Windows GDI library.

After performing several changes to the data in the range, Heap Walker

should report several new segments marked as discardable (a D should

appear in the FLG field), but these segments still remain in memory as

nondiscardable segments.

Every update to the Excel cells accessed through the DDE link will

create a SHARED segment owned by GDI that contains the data. These

segments will be approximately equal in size (the actual size depends

on the length of data that was entered in the cells and the size of

the selected range). If you view the contents of these SHARED segments

by choosing Show from the Object menu, you will see each data change

performed in Excel. The contents of the DDE message will be located

around offset 0600 in the segment view mode through Heap Walker.

References:

Microsoft Windows version 3.0 Software Development Kit

Additional reference words: 1.00 hot cold