This is the documentation for Enlighten.
module Memory Allocation
Classes
Name | Description |
---|---|
Geo::AnsiAllocator | Simple implementation of the MemoryAllocator class that forwards all requests to the malloc/free ANSI functions. |
Geo::GeoDebugAllocator | MemoryAllocator implementation which fills allocated memory with a given value. |
Geo::GeoMemoryDefault | Fully featured MemoryAllocator implementation that handles memory tracking, leak detection, stack traces, reporting and more. |
Geo::GeoVirtualPageAllocator | Implementation of the MemoryAllocator class (on Windows) that uses VirtualAlloc and VirtualProtect to provide similar memory overwrite detection as the Application Verifier. |
Geo::MemoryAllocator | Class used to override memory allocation and freeing. |
Functions
Name | Description |
---|---|
~MemoryAllocator() | Force a virtual destructor. This is not called by GeoMemory. |
Allocate(size_t, size_t, const char *, Geo::s32, const char *) | Allocate a block of memory with the given size. |
Free(void *, bool, const char *, Geo::s32, const char *) | Free a block of memory, possibly aligned. |
GEO_DELETE_ARRAY_T(T *&) | Templated function equivalent of GEO_DELETE_ARRAY A handy template so you don't have to enter the type param (and potentially get it wrong) |
GEO_DELETE_T(T *&) | Templated function equivalent of GEO_DELETE A handy template so you don't have to enter the type param (and potentially get it wrong) |
GeoDestruct(T &) | Calls destructor on object. |
GeoDestruct(v128 &) | Calls destructor on object. |
GetMemoryAllocator() | Gets the currently set memory allocator, or NULL if none has been set yet. |
GetNumPageFaults() | The number of page faults that occurred during the process life. |
GetPeakProcessMemoryInfo() | The peak amount of memory allocated by the process. |
GetTotalMemoryAllocated() | The total amount of memory we've allocated to date (not subtracting deallocations). |
GetTotalMemoryAllocationCalls() | The number of times we've allocated memory through GeoMemory. |
GetTotalMemoryDeallocated() | The total amount of memory we've deallocated so far. |
GetTotalMemoryInUse() | The total amount of memory currently allocated (allocations minus deallocations) |
GetTotalMemoryInUse() | The total amount of memory currently allocated (allocations minus deallocations) |
GetTotalProcessMemoryInfo() | The total amount of memory currently allocated by the process. |
GetTotalSystemMemory() | Get the total amount of system physical memory. |
IsTotalMemorySummarySupported() | Returns true if the memory summary functionality is supported with this allocator. |
MemoryTrackerReport(s16, bool) | This will generate a report on memory leaks, and attempt to release the leaks. |
PrintTotalMemorySummaryForMarker(const char *, const char *, s32) | Print a basic report to the LOG_INFO stream. |
Realloc(void *, size_t, size_t, const char *, s32, const char *) | Reallocate a block of memory, preserving as much data as will fit in the new block size. |
SafeRelease(T &) | Scoped safe release function. |
SetMemoryAllocator(MemoryAllocator *) | Set the memory allocator. |
Defines
Name | Description |
---|---|
GEO_ALIGNED_FREE Geo::AlignedFree(mem, __FILE__, __LINE__, GEO_STRINGISE(mem)); (mem) = NULL | Free memory previously allocated by GEO_ALIGNED_MALLOC. |
GEO_ALIGNED_MALLOC Geo::AlignedMalloc(size, align, __FILE__, __LINE__, GEO_STRINGISE(size) " " GEO_STRINGISE(align)) | Allocate memory of a given size and alignment. |
GEO_ALIGNED_NEW (new (Geo::AlignedMalloc(sizeof(type), align, __FILE__, __LINE__, GEO_STRINGISE(type))) type) | do a parameterless new of a given type using GEO_MALLOC |
GEO_ALIGNED_NEW_ARGS (new (Geo::AlignedMalloc(sizeof(type), align, __FILE__, __LINE__, GEO_STRINGISE(type) " " GEO_STRINGISE(args))) type args) | do a parameterized new of a given type using GEO_MALLOC |
GEO_DELETE if (mem) { (mem)->~type(); Geo::AlignedFree(mem, __FILE__, __LINE__, GEO_STRINGISE(type) " " GEO_STRINGISE(mem)); (mem) = nullptr; } | delete an object previously allocated by GEO_NEW or GEO_NEW_ARGS |
GEO_DELETE_ARRAY Geo::DeleteArray<type>(mem, __FILE__, __LINE__, GEO_STRINGISE(type) " " GEO_STRINGISE(mem)) | delete an array previously allocated using GEO_NEW_ARRAY |
GEO_DELETE_NS if (mem) { (mem)->ns::type::~type(); Geo::AlignedFree(mem, __FILE__, __LINE__, GEO_STRINGISE(type) " " GEO_STRINGISE(mem)); (mem) = NULL; } | delete an object previously allocated by GEO_NEW or GEO_NEW_ARGS when the type requires a namespace specification |
GEO_DELETE_THIS this->~type(); Geo::AlignedFree(this, __FILE__, __LINE__, GEO_STRINGISE(type) " " GEO_STRINGISE(mem)) | delete the underlying object pointed to by the this pointer. |
GEO_FREE Geo::Free(mem, __FILE__, __LINE__, GEO_STRINGISE(mem)); (mem) = NULL | Free memory previously allocated by GEO_MALLOC. |
GEO_INPLACE_DELETE if (mem) { (mem)->~type(); (mem) = 0; } | do an inplace delete |
GEO_INPLACE_NEW (new (mem) type) | do a parameterless inplace new |
GEO_INPLACE_NEW_ARGS (new (mem) type args) | do a parameterized inplace new |
GEO_MALLOC Geo::Malloc(size, __FILE__, __LINE__, GEO_STRINGISE(size)) | Allocate memory of a given size. |
GEO_MEM_AUDIT_MARKER Geo::PrintTotalMemorySummaryForMarker(name, __FILE__, __LINE__) | Place an audit marker that will generate a basic summary of the overall memory using the GetTotalMemory*() functions. |
GEO_NEW (new (Geo::AlignedMalloc(sizeof(type), GEO_ALIGN_OF(type), __FILE__, __LINE__, GEO_STRINGISE(type))) type) | do a parameterless new of a given type using GEO_MALLOC |
GEO_NEW_ARGS (new (Geo::AlignedMalloc(sizeof(type), GEO_ALIGN_OF(type), __FILE__, __LINE__, GEO_STRINGISE(type) " " GEO_STRINGISE(args))) type args) | do a parameterized new of a given type using GEO_MALLOC |
GEO_NEW_ARRAY Geo::NewArray<type>(length, GEO_ALIGN_OF(type), __FILE__, __LINE__, GEO_STRINGISE(type) " " GEO_STRINGISE(length)) | allocate a new array using GEO_ALIGNED_MALLOC, using the alignment of the type being allocated |
GEO_NEW_ARRAY_ALIGNED Geo::NewArray<type>(length, align, __FILE__, __LINE__, GEO_STRINGISE(type) " " GEO_STRINGISE(length)) | allocate a new array using GEO_ALIGNED_MALLOC, using whatever alignment is specified |
GEO_REALLOC Geo::Realloc(mem, size, align, __FILE__, __LINE__, GEO_STRINGISE(mem)) | Implements 'realloc' functionality (resize a memory block, retaining the data values that fit in the new size). |
GEO_UNSAFE_DELETE if (mem) { (mem)->~type(); Geo::AlignedFree(mem, __FILE__, __LINE__, GEO_STRINGISE(type) " " GEO_STRINGISE(mem)); } | like GEO_DELETE, but does not zero the pointer |
virtual Geo::MemoryAllocator::~MemoryAllocator
public: virtual ~MemoryAllocator()
Force a virtual destructor. This is not called by GeoMemory.
virtual void* Geo::MemoryAllocator::Allocate
public: void * Allocate
(
size_t size,
size_t align,
const char * filename,
Geo::s32 lineNumber,
const char * message
)
Allocate a block of memory with the given size.
If alignment is 0, use unaligned allocation. Otherwise, alignment must be a power of two.
virtual void Geo::MemoryAllocator::Free
public: void Free
(
void * mem,
bool aligned,
const char * filename,
Geo::s32 lineNumber,
const char * message
)
Free a block of memory, possibly aligned.
void Geo::GEO_DELETE_ARRAY_T
public: void GEO_DELETE_ARRAY_T
(
T *& p
)
Templated function equivalent of GEO_DELETE_ARRAY A handy template so you don't have to enter the type param (and potentially get it wrong)
Note
Make sure the pointer you are deleting is actually the allocated type and not a super class!
void Geo::GEO_DELETE_T
public: void GEO_DELETE_T
(
T *& p
)
Templated function equivalent of GEO_DELETE A handy template so you don't have to enter the type param (and potentially get it wrong)
Note
Make sure the pointer you are deleting is actually the allocated type and not a super class!
void Geo::GeoDestruct
public: void GeoDestruct
(
T & object
)
Calls destructor on object.
void Geo::GeoDestruct
public: void GeoDestruct
(
v128 &
)
Calls destructor on object.
MemoryAllocator* GEO_CALL Geo::GetMemoryAllocator
public: MemoryAllocator *GEO_CALL GetMemoryAllocator()
Gets the currently set memory allocator, or NULL if none has been set yet.
Geo::s64 GEO_CALL Geo::GetNumPageFaults
public: Geo::s64GEO_CALL GetNumPageFaults()
The number of page faults that occurred during the process life.
Geo::s64 GEO_CALL Geo::GetPeakProcessMemoryInfo
public: Geo::s64GEO_CALL GetPeakProcessMemoryInfo()
The peak amount of memory allocated by the process.
virtual Geo::s64 Geo::MemoryAllocator::GetTotalMemoryAllocated
public: virtual Geo::s64 GetTotalMemoryAllocated()
The total amount of memory we've allocated to date (not subtracting deallocations).
virtual Geo::s64 Geo::MemoryAllocator::GetTotalMemoryAllocationCalls
public: virtual Geo::s64 GetTotalMemoryAllocationCalls()
The number of times we've allocated memory through GeoMemory.
virtual Geo::s64 Geo::MemoryAllocator::GetTotalMemoryDeallocated
public: virtual Geo::s64 GetTotalMemoryDeallocated()
The total amount of memory we've deallocated so far.
virtual Geo::s64 Geo::MemoryAllocator::GetTotalMemoryInUse
public: virtual Geo::s64 GetTotalMemoryInUse()
The total amount of memory currently allocated (allocations minus deallocations)
Geo::s64 GEO_CALL Geo::GetTotalMemoryInUse
public: Geo::s64GEO_CALL GetTotalMemoryInUse()
The total amount of memory currently allocated (allocations minus deallocations)
Geo::s64 GEO_CALL Geo::GetTotalProcessMemoryInfo
public: Geo::s64GEO_CALL GetTotalProcessMemoryInfo()
The total amount of memory currently allocated by the process.
Geo::u64 GEO_CALL Geo::GetTotalSystemMemory
public: Geo::u64GEO_CALL GetTotalSystemMemory()
Get the total amount of system physical memory.
Returns
0 on error or if unsupported, otherwise the total system physical memory in bytes
virtual bool Geo::MemoryAllocator::IsTotalMemorySummarySupported
public: virtual bool IsTotalMemorySummarySupported()
Returns true if the memory summary functionality is supported with this allocator.
void GEO_CALL Geo::MemoryTrackerReport
public: void GEO_CALL MemoryTrackerReport
(
s16 exitCode,
bool pauseOnError
)
This will generate a report on memory leaks, and attempt to release the leaks.
It should be called when an application has shut down just before it exits completely. Because it attempts to release any leaks this must be the very last thing an application does.
Note
This doesn't do anything in a release build.
bool GEO_CALL Geo::PrintTotalMemorySummaryForMarker
public: bool GEO_CALL PrintTotalMemorySummaryForMarker
(
const char * name,
const char * filename,
s32 lineNumber
)
Print a basic report to the LOG_INFO stream.
Returns
Returns true if a log was printed. It will only be printed if IsTotalMemorySummarySupported() returns true.
virtual void* Geo::MemoryAllocator::Realloc
public: void * Realloc
(
void * mem,
size_t size,
size_t align,
const char * filename,
s32 lineNumber,
const char * message
)
Reallocate a block of memory, preserving as much data as will fit in the new block size.
Requires the same alignment as in the original allocation.
void Geo::SafeRelease
public: void SafeRelease
(
T & a
)
Scoped safe release function.
void GEO_CALL Geo::SetMemoryAllocator
public: void GEO_CALL SetMemoryAllocator
(
MemoryAllocator * allocator
)
Set the memory allocator.
You must call this before ANY other Geo calls are made. It can only be set once and cannot be unset. No Geo-derived module is robust to incomplete, slow or buggy MemoryAllocators so be careful!