5#include <Foundation/Time/Time.h>
6#include <Foundation/Types/ArrayPtr.h>
7#include <Foundation/Types/Id.h>
27 PL_DECLARE_POD_TYPE();
29 plUInt64 m_uiNumAllocations = 0;
30 plUInt64 m_uiNumDeallocations = 0;
31 plUInt64 m_uiAllocationSize = 0;
33 plUInt64 m_uiPerFrameAllocationSize = 0;
41 virtual void*
Allocate(
size_t uiSize,
size_t uiAlign, plMemoryUtils::DestructorFunction destructorFunc =
nullptr) = 0;
42 virtual void Deallocate(
void* pPtr) = 0;
43 virtual void* Reallocate(
void* pPtr,
size_t uiCurrentSize,
size_t uiNewSize,
size_t uiAlign);
53 virtual Stats GetStats()
const = 0;
59#include <Foundation/Memory/Implementation/Allocator_inl.h>
62#define PL_NEW(allocator, type, ...) \
63 plInternal::NewInstance<type>( \
64 new ((allocator)->Allocate(sizeof(type), PL_ALIGNMENT_OF(type), plMemoryUtils::MakeDestructorFunction<type>())) type(__VA_ARGS__), (allocator))
67#define PL_DELETE(allocator, ptr) \
69 plInternal::Delete(allocator, ptr); \
74#define PL_NEW_ARRAY(allocator, type, count) plInternal::CreateArray<type>(allocator, count)
77#define PL_DELETE_ARRAY(allocator, arrayPtr) \
79 plInternal::DeleteArray(allocator, arrayPtr); \
84#define PL_NEW_RAW_BUFFER(allocator, type, count) plInternal::CreateRawBuffer<type>(allocator, count)
87#define PL_DELETE_RAW_BUFFER(allocator, ptr) \
89 plInternal::DeleteRawBuffer(allocator, ptr); \
94#define PL_EXTEND_RAW_BUFFER(allocator, ptr, oldSize, newSize) plInternal::ExtendRawBuffer(ptr, allocator, oldSize, newSize)
99#define PL_DEFAULT_NEW(type, ...) PL_NEW(plFoundation::GetDefaultAllocator(), type, __VA_ARGS__)
102#define PL_DEFAULT_DELETE(ptr) PL_DELETE(plFoundation::GetDefaultAllocator(), ptr)
105#define PL_DEFAULT_NEW_ARRAY(type, count) PL_NEW_ARRAY(plFoundation::GetDefaultAllocator(), type, count)
108#define PL_DEFAULT_DELETE_ARRAY(arrayPtr) PL_DELETE_ARRAY(plFoundation::GetDefaultAllocator(), arrayPtr)
111#define PL_DEFAULT_NEW_RAW_BUFFER(type, count) PL_NEW_RAW_BUFFER(plFoundation::GetDefaultAllocator(), type, count)
114#define PL_DEFAULT_DELETE_RAW_BUFFER(ptr) PL_DELETE_RAW_BUFFER(plFoundation::GetDefaultAllocator(), ptr)
Base class for all memory allocators.
Definition Allocator.h:23
virtual void * Allocate(size_t uiSize, size_t uiAlign, plMemoryUtils::DestructorFunction destructorFunc=nullptr)=0
Interface, do not use this directly, always use the new/delete macros below.
virtual size_t AllocatedSize(const void *pPtr)=0
Returns the number of bytes allocated at this address.
Definition Allocator.h:26
plTime m_PerFrameAllocationTime
time spend on allocations in this frame
Definition Allocator.h:34
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12