CComHeap Class
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at CComHeap Class.
This class implements IAtlMemMgr using the COM memory allocation functions.
This class and its members cannot be used in applications that execute in the Windows Runtime. |
class CComHeap : public IAtlMemMgr
Public Methods
| Name | Description |
|---|---|
| CComHeap::Allocate | Call this method to allocate a block of memory. |
| CComHeap::Free | Call this method to free a block of memory allocated by this memory manager. |
| CComHeap::GetSize | Call this method to get the allocated size of a memory block allocated by this memory manager. |
| CComHeap::Reallocate | Call this method to reallocate memory allocated by this memory manager. |
CComHeap implements memory allocation functions using the COM allocation functions, including CoTaskMemAlloc, CoTaskMemFree, IMalloc::GetSize, and CoTaskMemRealloc. The maximum amount of memory that can be allocated is equal to INT_MAX (2147483647) bytes.
See the example for IAtlMemMgr.
IAtlMemMgr
CComHeap
Header: ATLComMem.h
Call this method to allocate a block of memory.
virtual __declspec(allocator) void* Allocate(size_t nBytes) throw();
Parameters
nBytes
The requested number of bytes in the new memory block.
Return Value
Returns a pointer to the start of the newly allocated memory block.
Remarks
Call CComHeap::Free or CComHeap::Reallocate to free the memory allocated by this method.
Implemented using CoTaskMemAlloc.
Call this method to free a block of memory allocated by this memory manager.
virtual void Free(void* p) throw();
Parameters
p
Pointer to memory previously allocated by this memory manager. NULL is a valid value and does nothing.
Remarks
Implemented using CoTaskMemFree.
Call this method to get the allocated size of a memory block allocated by this memory manager.
virtual size_t GetSize(void* p) throw();
Parameters
p
Pointer to memory previously allocated by this memory manager.
Return Value
Returns the size of the allocated memory block in bytes.
Remarks
Implemented using IMalloc::GetSize.
Call this method to reallocate memory allocated by this memory manager.
virtual __declspec(allocator) void* Reallocate(void* p, size_t nBytes) throw();
Parameters
p
Pointer to memory previously allocated by this memory manager.
nBytes
The requested number of bytes in the new memory block.
Return Value
Returns a pointer to the start of the newly allocated memory block.
Remarks
Call CComHeap::Free to free the memory allocated by this method.
Implemented using CoTaskMemRealloc.
DynamicConsumer Sample
Class Overview
CWin32Heap Class
CLocalHeap Class
CGlobalHeap Class
CCRTHeap Class
IAtlMemMgr Class