Removing Memory Leaks

Memory leaks decrease the available memory and increase disk swapping. They also reduce stability, degrade performance over time, and can eventually bring your computer to a halt. Because a number of MAPI functions allocate memory for you, but do not free it, you must remember to free this memory yourself. Many tools are available to help you find memory leaks.

Do not assume that all the leaks you detect are your own. If one application uses the DLL of another application, this DLL may cause a memory leak, although the original application may appear to be causing the problem.

The Windows NT Server Resource Kit and the Platform SDK contain tools to help you with memory leak detection for Windows NT Server and Windows 95. For more information, see Using a Debug Version of MAPI and The Microsoft Windows NT Advanced Server System Guide.

Using GlobalAlloc, HeapAlloc, and MAPIAllocateBuffer

The Win 32 GlobalAlloc and HeapAlloc functions and the MAPIAllocateBuffer functions are designed for memory management. A 32-bit application should use the HeapAlloc function for the best performance.

For a complete discussion about memory allocation options and performance, see Options for Memory Management.