PxBroadcastingAllocator

Defined in include/foundation/PxBroadcast.h

class PxBroadcastingAllocator : public PxBroadcast<PxAllocationListener, PxAllocatorCallback>

Abstract base class for an application defined memory allocator that allows an external listener to audit the memory allocations.

Public Functions

inline PxBroadcastingAllocator(PxAllocatorCallback &allocator, PxErrorCallback &error)

The default constructor.

inline virtual ~PxBroadcastingAllocator()

The default constructor.

inline virtual void *allocate(size_t size, const char *typeName, const char *filename, int line)

Allocates size bytes of memory, which must be 16-byte aligned.

This method should never return NULL. If you run out of memory, then you should terminate the app or take some other appropriate action.

Threading: This function should be thread safe as it can be called in the context of the user thread and physics processing thread(s).

Parameters
  • size – Number of bytes to allocate.

  • typeName – Name of the datatype that is being allocated

  • filename – The source file which allocated the memory

  • line – The source line which allocated the memory

Returns

The allocated block of memory.

inline virtual void deallocate(void *ptr)

Frees memory previously allocated by allocate().

Threading: This function should be thread safe as it can be called in the context of the user thread and physics processing thread(s).

Parameters

ptr – Memory to free.

inline void registerListener(PxAllocationListener &listener)

Register new listener.

Note

It is NOT SAFE to register and deregister listeners while allocations may be taking place. moreover, there is no thread safety to registration/deregistration.

Parameters

listener – Listener to register.

inline void deregisterListener(PxAllocationListener &listener)

Deregister an existing listener.

Note

It is NOT SAFE to register and deregister listeners while allocations may be taking place. moreover, there is no thread safety to registration/deregistration.

Parameters

listener – Listener to deregister.

inline uint32_t getNbListeners() const

Get number of registered listeners.

Returns

Number of listeners.

inline PxAllocationListener &getListener(uint32_t index)

Get an existing listener from given index.

Parameters

index – Index of the listener.

Returns

Listener on given index.

Public Static Attributes

static const uint32_t MAX_NB_LISTENERS

Protected Attributes

physx::PxInlineArray<PxAllocationListener*, MAX_NB_LISTENERS, physx::PxAllocator> mListeners