MDL SDK API nvidia_logo_transpbg.gif Up
Memory Management

The memory management provides an interface for allocators. More...

Classes

class  mi::base::IAllocator
 The IAllocator interface class supports allocating and releasing memory dynamically. More...
 

Functions

virtual void * mi::base::IAllocator::malloc (Size size)=0
 Allocates a memory block of the given size. More...
 
virtual void mi::base::IAllocator::free (void *memory)=0
 Releases the given memory block. More...
 

Detailed Description

The memory management provides an interface for allocators.

You can request dynamic memory from an allocator implementation through an mi::base::IAllocator interface.

Function Documentation

 free()

virtual void mi::base::IAllocator::free ( void *  memory)
pure virtual

Releases the given memory block.

This function can be called at any time from any thread, including concurrent calls from several threads at the same time.

Parameters
memoryA memory block previously allocated by a call to malloc(). If memory is nullptr, no operation is performed.

Implemented in mi::neuraylib::IAllocator.

 malloc()

virtual void * mi::base::IAllocator::malloc ( Size  size)
pure virtual

Allocates a memory block of the given size.

The memory must be aligned to an address which can accommodate any type of object on the current platform.

An allocation of zero bytes returns a valid non-null pointer which must be freed in the end. However, dereferencing this pointer gives undefined behavior.

This function can be called at any time from any thread, including concurrent calls from several threads at the same time.

If the requested memory is not available this function returns nullptr. Some products give the stronger guarantee that allocation can never fail. (They can do this, for example, by flushing parts or in its extreme, stop executing.) See the API documentation of the specific products for specific allocator interfaces or allocator documentation.

Parameters
sizeThe requested size of memory in bytes. It may be zero.
Returns
The allocated memory block.

Implemented in mi::neuraylib::IAllocator.