Microsoft KB Archive/842922

= A handle leak occurs in MAPI when you create an IMAPIFolder object by using the IMsgStore::OpenEntry method in Exchange 2000 Server or in Exchange Server 2003 =

Article ID: 842922

Article Last Modified on 10/25/2007

-

APPLIES TO


 * Microsoft Exchange Server 2003 Enterprise Edition
 * Microsoft Exchange Server 2003 Standard Edition
 * Microsoft Exchange 2000 Server Standard Edition
 * Microsoft Exchange 2000 Enterprise Server

-





SYMPTOMS
When you programmatically create an IMAPIFolder object by using the IMsgStore::OpenEntry method, you experience both of the following symptoms:
 * Your program eventually stops responding because of memory-related exception errors.
 * If you troubleshoot the cause of the memory issue by viewing the Handles counter in the Performance tool, you notice that handles are not released in your program's executable file for the Messaging Database (MDB) that you opened.



CAUSE
This issue occurs if you release the IMsgStore object before you release the IMAPIFolder object that you created by using the IMsgStore::OpenEntry method. Because of security changes in Microsoft Exchange 2000 Server and in Microsoft Exchange Server 2003, you must release the IMAPIFolder object before you release the IMsgStore object in that MDB.



RESOLUTION
To resolve this issue, release the IMAPIFolder object that is created by the IMsgStore::OpenEntry method before you release the IMsgStore object.



MORE INFORMATION
For additional information about the MAPI IMsgStore::OpenEntry method, visit the following Microsoft Web site:

http://msdn2.microsoft.com/en-us/library/ms837628.aspx

Depending on the fifth parameter in the IMsgStore::OpenEntry method, the sixth parameter in the IMsgStore::OpenEntry method returns a pointer to an IMAPIFolder object or to an IMessage object. The issue that is described in this article is particularly noticeable when the MAPI interfaces are wrapped in Active Template Library (ATL) smart pointers or in Component Object Model (COM) smart pointers. Upon destruction, the ATL smart pointer or the COM smart pointer automatically makes calls to the COM interface Release method that is associated with that particular COM object. If you declare smart pointers around IMAPIFolder and IMsgStore and you then permit them to pass &quot;out of existence,&quot; you experience the handle leak that is described in this article. Therefore, make an explicit call to the Release method for IMAPIFolder first, and then make the call to the Release method for IMsgStore.

For additional MAPI documentation, see the Microsoft Platform Software Development Kit (SDK). To obtain the Platform SDK, visit the following Microsoft Web site:

http://www.microsoft.com/msdownload/platformsdk/sdkupdate/

Additional query words: MAPI Handle Leak Exchange 2000 2003 IMAPIFolder IMsgStore LPMAPIFOLDER LPMDB

Keywords: kbdiskmemory kbenv kbprb KB842922

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.