Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This interface allocates, frees, and manages memory.
When to Implement
In general, you should not implement IMalloc, instead use the COM implementation, which is guaranteed to be thread-safe in managing task memory. You get a pointer to the COM task allocator object's IMallocthrough a call to the CoGetMallocfunction.
When to Use
Call the methods of IMallocto allocate and manage memory. The COM libraries and object handlers also call the IMallocmethods to manage memory.
Object handlers should call CoGetMallocto get a pointer to the IMallocimplementation on the task allocator object and use the implementation of those methods to manage task memory.
The IMallocmethods Alloc, Free, and Reallocare similar to the C library functions malloc, free, and realloc. For debugging, refer to the functions CoRegisterMallocSpyand CoRevokeMallocSpy.
Methods
The following table shows the methods for this interface in the order that the compiler calls the methods. Like all COM interfaces, this interface inherits the methods for the IUnknowninterface.
IUnknown method | Description |
---|---|
Returns pointers to supported interfaces. |
|
Increments reference count. |
|
Decrements reference count. |
IMalloc method | Description |
---|---|
Allocates a block of memory. |
|
Changes the size of a previously allocated block of memory. |
|
Frees a previously allocated block of memory. |
|
Returns the size in bytes of a previously allocated block of memory. |
|
Determines whether this instance of IMallocwas used to allocate the specified block of memory. |
|
Minimizes the heap by releasing unused memory to the operating system. |
Remarks
To determine whether the platform supports this interface, see Determining Supported COM APIs.
Requirements
Header | objidl.h, objidl.idl |
Library | ole32.lib |
Windows Embedded CE | Windows CE 3.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |