description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: CGlobalHeap Class |
CGlobalHeap Class |
11/04/2016 |
|
|
e348d838-3aa7-4bee-a1b3-cd000c99f834 |
This class implements IAtlMemMgr using the Win32 global heap functions.
Important
This class and its members cannot be used in applications that execute in the Windows Runtime.
class CGlobalHeap : public IAtlMemMgr
Name | Description |
---|---|
CGlobalHeap::Allocate | Call this method to allocate a block of memory. |
CGlobalHeap::Free | Call this method to free a block of memory allocated by this memory manager. |
CGlobalHeap::GetSize | Call this method to get the allocated size of a memory block allocated by this memory manager. |
CGlobalHeap::Reallocate | Call this method to reallocate memory allocated by this memory manager. |
CGlobalHeap
implements memory allocation functions using the Win32 global heap functions.
Note
The global heap functions are slower than other memory management functions and do not provide as many features. Therefore, new applications should use the heap functions. These are available in the CWin32Heap class. Global functions are still used by DDE and the clipboard functions.
See the example for IAtlMemMgr.
IAtlMemMgr
CGlobalHeap
Header: atlmem.h
Call this method to allocate a block of memory.
virtual __declspec(allocator) void* Allocate(size_t nBytes) throw();
nBytes
The requested number of bytes in the new memory block.
Returns a pointer to the start of the newly allocated memory block.
Call CGlobalHeap::Free or CGlobalHeap::Reallocate to free the memory allocated by this method.
Implemented using GlobalAlloc with a flag parameter of GMEM_FIXED.
Call this method to free a block of memory allocated by this memory manager.
virtual void Free(void* p) throw();
p
Pointer to memory previously allocated by this memory manager. NULL is a valid value and does nothing.
Implemented using GlobalFree.
Call this method to get the allocated size of a memory block allocated by this memory manager.
virtual size_t GetSize(void* p) throw();
p
Pointer to memory previously allocated by this memory manager.
Returns the size of the allocated memory block in bytes.
Implemented using GlobalSize.
Call this method to reallocate memory allocated by this memory manager.
virtual __declspec(allocator) void* Reallocate(void* p, size_t nBytes) throw();
p
Pointer to memory previously allocated by this memory manager.
nBytes
The requested number of bytes in the new memory block.
Returns a pointer to the start of the newly allocated memory block.
Call CGlobalHeap::Free to free the memory allocated by this method.
Implemented using GlobalReAlloc.
Class Overview
CComHeap Class
CWin32Heap Class
CLocalHeap Class
CCRTHeap Class
IAtlMemMgr Class