BUG: Memory Problems with Simple Mapi (169680)



The information in this article applies to:

  • Microsoft Exchange Server 5.0
  • Microsoft Exchange Server 4.0

This article was previously published under Q169680

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.

MORE INFORMATION




Modification Type:MajorLast Reviewed:3/19/2004
Keywords:kbbug kbSMAPICMC KB169680