Material Definition Language API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mi::neuraylib::IAllocator Class Referenceabstract

The Allocator interface class supports allocating and releasing memory dynamically and querying the amount of extra memory used in the integrating application. More...

Inheritance diagram for mi::neuraylib::IAllocator:
mi::base::Interface_declare< 0x952af060, 0xe2a6, 0x4bd7, 0xa2, 0x52, 0x9f, 0x6d, 0x39, 0xfb, 0x50, 0xa3, base::IAllocator > mi::base::IAllocator mi::base::Interface_declare< 0xa1836db8, 0x6f63, 0x4079, 0x82, 0x82, 0xb3, 0x5d, 0x17, 0x36, 0x96, 0xef > mi::base::IInterface

Public Member Functions

virtual void * malloc (Size size)=0
 Allocates a memory block of the given size. More...
 
virtual void free (void *memory)=0
 Releases the given memory block. More...
 
virtual Size get_used_extra_memory ()=0
 This function is used by the MDL API to inquire the amount of extra memory currently in use in the application. More...
 

Additional Inherited Members

- Public Types inherited from mi::base::Interface_declare< 0x952af060, 0xe2a6, 0x4bd7, 0xa2, 0x52, 0x9f, 0x6d, 0x39, 0xfb, 0x50, 0xa3, base::IAllocator >
typedef Interface_declare< id1,
id2, id3, id4, id5, id6, id7,
id8, id9, id10, id11,
base::IAllocator
Self
 Own type. More...
 
typedef Uuid_t< id1, id2, id3,
id4, id5, id6, id7, id8, id9,
id10, id11 > 
IID
 Declares the interface ID (IID) of this interface. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0x952af060, 0xe2a6, 0x4bd7, 0xa2, 0x52, 0x9f, 0x6d, 0x39, 0xfb, 0x50, 0xa3, base::IAllocator >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 

Detailed Description

The Allocator interface class supports allocating and releasing memory dynamically and querying the amount of extra memory used in the integrating application.

You can provide your own allocator object implementing this interface at initialization time of the MDL API library to have the MDL API use your memory management.

Member Function Documentation

virtual void mi::neuraylib::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 NULL, no operation is performed.

Implements mi::base::IAllocator.

virtual Size mi::neuraylib::IAllocator::get_used_extra_memory ( )
pure virtual

This function is used by the MDL API to inquire the amount of extra memory currently in use in the application.

This function may be called frequently and must be implemented efficiently.

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

virtual void* mi::neuraylib::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 must return NULL. In this case the MDL API will try to reduce the memory it uses and retry the allocation. If allocation still fails the MDL API will give up. In this case the MDL API can not be used anymore and must be shut down. The MDL API will try to release as much memory as possible but it can not be guaranteed that all memory is returned. It is not possible to restart the library after a failure without restarting the process.

Plugins for the MDL API will get an allocator implementation that uses the MDL API memory management to give the stronger guarantee that allocation can never fail.

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

Implements mi::base::IAllocator.