IMalloc  0K__0K

Allocates, frees, and manages memory.

When to Implement

In general, you should not implement IMalloc, instead using the OLE implementation, which is guaranteed to be thread-safe in managing task memory. You get a pointer to the OLE task allocator object s IMalloc through a call to the CoGetMalloc1012PPO function.

When to Use

Call the methods of IMalloc to allocate and manage memory. The OLE libraries and object handlers also call the IMalloc methods to manage memory. Object handlers should call CoGetMalloc1012PPO to get a pointer to the IMalloc implementation on the task allocator object, and use the implementation of those methods to manage task memory.

The IMalloc methods Alloc, Free, and Realloc are similar to the C library functions malloc, free, and realloc. For debugging, refer to the functions CoRegisterMallocSpySX_AGF and CoRevokeMallocSpy136T3F..

Methods in Vtable Order

IUnknown1NEM0LU Methods

Description

QueryInterface2Y54585

Returns pointers to supported interfaces.

AddRef1SHW0SS

Increments the reference count.

ReleaseDUW01A

Decrements the reference count.

 

IMalloc Methods

Description

Alloc1THWWZM

Allocates a block of memory.

Realloc5HRJV.

Changes the size of a previously allocated block of memory.

Free62NW.NT

Frees a previously allocated block of memory.

GetSize65AX.OK

Returns the size in bytes of a previously allocated block of memory.

DidAlloc4NPHFW

Determines if this instance of IMalloc was used to allocate the specified block of memory.

HeapMinimize329F535

Minimizes the heap by releasing unused memory to the operating system.

 

See Also

CoGetMalloc, IMallocSpy, CoRegisterMallocSpy, CoRevokeMallocSpy