Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 1.53 KB

the-ole-memory-allocator.md

File metadata and controls

27 lines (18 loc) · 1.53 KB
title description ms.assetid ms.topic ms.date
The OLE Memory Allocator
The OLE Memory Allocator
026c62e5-c296-4059-b028-77c98fdb77ce
article
05/31/2018

The OLE Memory Allocator

The COM library provides an implementation of a memory allocator that is thread-safe. (That is, it cannot cause problems in multithreaded situations.) Whenever ownership of an allocated chunk of memory is passed through a COM interface or between a client and the COM library, you must use this COM allocator to allocate the memory. Allocation internal to an object can use any allocation scheme desired, but the COM memory allocator is a handy, efficient, and thread-safe allocator.

A call to the API function CoGetMalloc provides a pointer to the OLE allocator, which is an implementation of the IMalloc interface. However, it is more efficient to call the helper functions CoTaskMemAlloc, CoTaskMemRealloc, and CoTaskMemFree, which wrap getting a pointer to the task memory allocator, calling the corresponding IMalloc method, and then releasing the pointer to the allocator.

Related topics

Managing Memory Allocation

The COM Library