module Memory Allocation

This is the documentation for Enlighten.

module Memory Allocation

Classes

Name

Description

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

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

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