INFO: Possible Causes for Memory Leaks in MAPI Clients/Providers

ID: Q188958


The information in this article applies to:
  • Extended Messaging Application Programming Interface (MAPI), version 1.0


SUMMARY

During testing and deployment of an Extended Messaging Application Programming Interface (MAPI) client or service provider, it may appear that the application is leaking memory. It is often difficult to find the exact cause of a memory leak. This article lists several possible reasons for memory leaks in MAPI client or service provider applications.


MORE INFORMATION

There are several logic errors that may cause this problem. A list of possible reasons follows. This is not a comprehensive list, but it does cover the most common problems developers have run into in their code.

  • Not releasing interfaces.


  • Not freeing returned data (for example, row sets, address lists, and properties)


  • Not allocating using MAPIAllocateBuffer or MAPIAllocateMore.


  • Incorrect reference counting on interfaces you implemented.


  • Not initializing reference counting variable in an interface you implement.


Any memory allocated on your behalf by the MAPI subsystem should be released and set to NULL. This includes pointers to interfaces, structures, and any other data types that MAPI deals with. The common rule of thumb is "If MAPI gives it to you, free it or release it."

Make sure you always use the MAPIAllocateBuffer, MAPIAllocateMore and MAPIFreeBuffer functions to allocate and deallocate memory off of the heap space.

When implementing your own interfaces, be sure to follow the rules of COM as strictly as possible to guarantee minimum memory loss from your application.

Additional query words: kbMsg kbMAPI100 kbMAPI

Keywords :
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: November 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.