DiCE API nvidia_logo_transpbg.gif Up
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...

#include <iallocator.h>

Inheritance diagram for mi::neuraylib::IAllocator:

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 DiCE to inquire the amount of extra memory currently in use in the application. More...
 
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...
 
- Public Member Functions inherited from mi::base::IInterface
virtual Uint32 retain () const =0
 Increments the reference count. More...
 
virtual Uint32 release () const =0
 Decrements the reference count. More...
 
virtual const IInterfaceget_interface (const Uuid &interface_id) const =0
 Acquires a const interface from another. More...
 
template<class T>
const T * get_interface () const
 Acquires a const interface from another. More...
 
virtual IInterfaceget_interface (const Uuid &interface_id)=0
 Acquires a mutable interface from another. More...
 
template<class T>
T * get_interface ()
 Acquires a mutable interface from another. More...
 
virtual Uuid get_iid () const =0
 Returns the interface ID of the most derived interface. More...
 

Additional Inherited Members

- Public Types inherited from mi::base::Interface_declare< 0x952af060, ... >
typedef Interface_declare< id1, ... > Self
 Own type. More...
 
typedef Uuid_t< id1, ... > IID
 Declares the interface ID (IID) of this interface. More...
 
- Public Types inherited from mi::base::Interface_declare< 0xa1836db8, ... >
typedef Interface_declare< id1, ... > Self
 Own type. More...
 
typedef Uuid_t< id1, ... > IID
 Declares the interface ID (IID) of this interface. More...
 
- Public Types inherited from mi::base::IInterface
typedef Uuid_t<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0> IID
 Declares the interface ID (IID) of this interface. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0x952af060, ... >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0xa1836db8, ... >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 
- Static Public Member Functions inherited from mi::base::IInterface
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface. 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 DiCE library to have the DiCE API use your memory management.

Member Function Documentation

 free()

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.

 get_used_extra_memory()

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

This function is used by DiCE 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.

 malloc()

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 DiCE will try to reduce the memory it uses and retry the allocation. If allocation still fails DiCE will give up. In this case DiCE can not be used anymore and must be shut down. DiCE 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 DiCE API will get an allocator implementation that uses DiCE 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.