Accessing and Customizing the Memory Allocator
Let’s start by defining a custom function for allocations performed using the ‘new’ operator:
void* myCustomNew( size_t size )
{
// Here, set your own memory management code!
return NULL;
}
Then, we can access the RED::MemoryAllocator and replace the current function by our new function:
// The memory allocator is a singleton:
RED::MemoryAllocator& mal = RED::MemoryAllocator::Get();
// Let's override the 'new' method:
mal.SetCustomNew( myCustomNew );
For simplicity, we do only replace one single memory function in the example above. To fully customize the memory management in HOOPS Luminate, all functions defined in the RED::MemoryAllocator
class should be replaced by the application.