Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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.

↑ Back to the top


Resolution

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

↑ Back to the top


More information

For additional information about the MAPI IMsgStore::OpenEntry() method, visit the following Microsoft Web site: 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 "out of existence," 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:

↑ Back to the top


Keywords: KB842922, kbprb, kbenv, kbdiskmemory

↑ Back to the top

Article Info
Article ID : 842922
Revision : 4
Created on : 10/25/2007
Published on : 10/25/2007
Exists online : False
Views : 312