Freeing Memory in a DDEML Server Application

Last reviewed: November 2, 1995
Article ID: Q83413
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) versions 3.1
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.5 and 3.51
        - Microsoft Windows 95 version 4.0
    

SUMMARY

A Dynamic Data Exchange Management Library (DDEML) server application calls the DdeCreateDataHandle function to allocate a block of memory for data it will send to a client application. DdeCreateDataHandle returns a handle to a block of memory that can be passed between applications.

The server application owns every data handle it creates. However, it is not necessary to call DdeFreeDataHandle under every circumstance. This article details the circumstances under which the server application must call DdeFreeDataHandle and when the DDEML will automatically free a data handle.

MORE INFORMATION

If the server application specifies the HDATA_APPOWNED flag in the afCmd parameter to DdeCreateDataHandle, it must explicitly call DdeFreeDataHandle to free the memory handle. Using HDATA_APPOWNED data handles is convenient when data, such as system topic information, is likely to be passed to a client application more than once, because the server calls DdeCreateDataHandle only once, regardless of the number of times the data handle is passed to a client application.

When it closes down, a server application must call DdeFreeDataHandle for each data handle that it has not passed to a client application. When the server creates a handle without specifying HDATA_APPOWNED, and passes the handle to a client application in an asynchronous transaction, the DDEML frees the data handle when the client returns from its callback function. Therefore, the server is not required to free the data handle it passes to a client because the DDEML frees the handle. However, if the data handle is never sent to a client application, the server must call DdeFreeDataHandle to free the handle. It is the client application's responsibility to call DdeFreeDataHandle for any data provided by a server in a synchronous transaction.


Additional reference words: 3.10 3.50 3.51 4.00 95
KBCategory: kbui
KBSubcategory: UsrDde


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: November 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.