Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Classes

NameDescription
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

NameDescription
~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

NameDescription
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


Anchor
a7acf643b8e4a54ca5884d64c2a8233c8
a7acf643b8e4a54ca5884d64c2a8233c8

virtual Geo::MemoryAllocator::~MemoryAllocator

...

public: virtual ~MemoryAllocator()

...

Force a virtual destructor. This is not called by GeoMemory.


Anchor
a1ad7d61101838a39ceed4f6e26544f5a
a1ad7d61101838a39ceed4f6e26544f5a

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.


Anchor
a0fc025f53e6435fec6b7589083aebbb6
a0fc025f53e6435fec6b7589083aebbb6

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.


Anchor
a9693b10c193bc5d2cb873063c6c1a07b
a9693b10c193bc5d2cb873063c6c1a07b

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
titleNote

Make sure the pointer you are deleting is actually the allocated type and not a super class!


Anchor
afac5d3ca3826d5b6f8cbc7057e0999d2
afac5d3ca3826d5b6f8cbc7057e0999d2

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
titleNote

Make sure the pointer you are deleting is actually the allocated type and not a super class!


Anchor
a1ce392363a20f02519819a1a87e385eb
a1ce392363a20f02519819a1a87e385eb

void Geo::GeoDestruct

...

public: void GeoDestruct
(
    T & object
)

...

Calls destructor on object.


Anchor
aff0bf1338afd82cecd42dab8fb72fd80
aff0bf1338afd82cecd42dab8fb72fd80

void Geo::GeoDestruct

...

public: void GeoDestruct
(
    v128 &
)

...

Calls destructor on object.


Anchor
a379e693760b39c0518a4d5b912e5a96e
a379e693760b39c0518a4d5b912e5a96e

MemoryAllocator* GEO_CALL Geo::GetMemoryAllocator

...

public: MemoryAllocator *GEO_CALL GetMemoryAllocator()

...

Gets the currently set memory allocator, or NULL if none has been set yet.


Anchor
a78a01af62f41c2975edd4416c7642dc9
a78a01af62f41c2975edd4416c7642dc9

Geo::s64 GEO_CALL Geo::GetNumPageFaults

...

public: Geo::s64GEO_CALL GetNumPageFaults()

...

The number of page faults that occurred during the process life.


Anchor
a1922bfb4ccbd4e94ddbe806e61e9b579
a1922bfb4ccbd4e94ddbe806e61e9b579

Geo::s64 GEO_CALL Geo::GetPeakProcessMemoryInfo

...

public: Geo::s64GEO_CALL GetPeakProcessMemoryInfo()

...

The peak amount of memory allocated by the process.


Anchor
a8d1f225f2ebcde9415cb3fa3e53d66d6
a8d1f225f2ebcde9415cb3fa3e53d66d6

virtual Geo::s64 Geo::MemoryAllocator::GetTotalMemoryAllocated

...

public: virtual Geo::s64 GetTotalMemoryAllocated()

...

The total amount of memory we've allocated to date (not subtracting deallocations).


Anchor
ae599af57b73a23ee1d2883a202178bc4
ae599af57b73a23ee1d2883a202178bc4

virtual Geo::s64 Geo::MemoryAllocator::GetTotalMemoryAllocationCalls

...

public: virtual Geo::s64 GetTotalMemoryAllocationCalls()

...

The number of times we've allocated memory through GeoMemory.


Anchor
a6c4a211d30c4600a93b22d84a78c01b3
a6c4a211d30c4600a93b22d84a78c01b3

virtual Geo::s64 Geo::MemoryAllocator::GetTotalMemoryDeallocated

...

public: virtual Geo::s64 GetTotalMemoryDeallocated()

...

The total amount of memory we've deallocated so far.


Anchor
a94fcfab1a68e8e593eaa8c7d30301639
a94fcfab1a68e8e593eaa8c7d30301639

virtual Geo::s64 Geo::MemoryAllocator::GetTotalMemoryInUse

...

public: virtual Geo::s64 GetTotalMemoryInUse()

...

The total amount of memory currently allocated (allocations minus deallocations)


Anchor
a1b062c0f7ea9d3c2140f9b562fd97281
a1b062c0f7ea9d3c2140f9b562fd97281

Geo::s64 GEO_CALL Geo::GetTotalMemoryInUse

...

public: Geo::s64GEO_CALL GetTotalMemoryInUse()

...

The total amount of memory currently allocated (allocations minus deallocations)


Anchor
a51a89ab80484b87c7cc70e64aa44c0ca
a51a89ab80484b87c7cc70e64aa44c0ca

Geo::s64 GEO_CALL Geo::GetTotalProcessMemoryInfo

...

public: Geo::s64GEO_CALL GetTotalProcessMemoryInfo()

...

The total amount of memory currently allocated by the process.


Anchor
a620e5610e2058d0620dbfc17645ab8bc
a620e5610e2058d0620dbfc17645ab8bc

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


Anchor
a3fddad784ad8df094175215b0e74d259
a3fddad784ad8df094175215b0e74d259

virtual bool Geo::MemoryAllocator::IsTotalMemorySummarySupported

...

public: virtual bool IsTotalMemorySummarySupported()

...

Returns true if the memory summary functionality is supported with this allocator.


Anchor
a80c945ffe89e23ae57d151e0e39d63e5
a80c945ffe89e23ae57d151e0e39d63e5

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
titleNote

This doesn't do anything in a release build.


Anchor
a188352efa82070e247cf0f02bbe0b3de
a188352efa82070e247cf0f02bbe0b3de

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.


Anchor
a5e7edc1e44ef98a103e58bd0367dba12
a5e7edc1e44ef98a103e58bd0367dba12

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.


Anchor
a67b6510c51ee91edbf28d21ab9735f21
a67b6510c51ee91edbf28d21ab9735f21

void Geo::SafeRelease

...

public: void SafeRelease
(
    T & a
)

...

Scoped safe release function.


Anchor
ace9c9821c7252bd16bc3b71a6fdfce86
ace9c9821c7252bd16bc3b71a6fdfce86

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!