BUG: Memory Problems with Simple Mapi

Last reviewed: July 25, 1997
Article ID: Q169680
The information in this article applies to:
  • Microsoft Exchange Server, version 5.0
  • Microsoft Exchange Server, version 4.0

SYMPTOMS

When writing an application that uses simple MAPI you may encounter Memory leaks.

CAUSE

Repeated calls to MAPILogoff() within the same application may result in a significant memory leaks. An example would be if a programmer designed an application that needed to periodically poll for new messages. A poorly optimized algorithm would appear like this:

   Do Until Something
   MAPILogon()
   MAPIResolveName()
   MAPIFindNext()
   MAPIFreeBuffer()
   MAPILogoff()
   Sleep()
   Loop

RESOLUTION

Instead you should Cache the MAPI Session, changing the example to this:

   MAPILogon()
   MAPIResolveName()
   Do Until Something
   MAPIFindNext()
   Sleep()
   Loop
   MAPILogoff()

You could also use Extended MAPI to avoid this problem.

Keywords          : SMapiCMC
Version           : 4.0 5.0
Platform          : IDEAS WINDOWS
Issue type        : kbbug
Solution Type     : kbfix


================================================================================


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: July 25, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.