2
3
4
5
6
7
9#ifndef GIMBAL_ALLOCATION_TRACKER_H
10#define GIMBAL_ALLOCATION_TRACKER_H
12#include "../core/gimbal_typedefs.h"
13#include "gimbal/core/gimbal_stack_frame.h"
15#define GBL_SELF_TYPE GblAllocationTracker
28} GblAllocationCounters;
36} GblAllocationTracker;
39
40
41
42
50
51
52
53
63 const void* pExisting,
75
76
77
78
87
88
89
90
96 const GblAllocationCounters* pSrc,
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
Counters for memory allocation and event statistics.
ptrdiff_t bytesActive
Current number of bytes active.
size_t allocEvents
Total number of allocations.
ptrdiff_t allocsActive
Current number of allocations active.
size_t bytesFreed
Total number of bytes freed.
size_t freeEvents
Total number of frees.
size_t reallocEvents
Total number of reallocations.
size_t bytesAllocated
Total number of bytes allocated.
Structure used for tracking allocation events and statistics.
GBL_EXPORT GBL_RESULT GblAllocationTracker_allocEvent(GBL_SELF, const void *pPtr, size_t size, size_t align, const char *pDbg, GblSourceLocation srcLoc) GBL_NOEXCEPT
To be called every time an allocation has been requested, to track the event.
GBL_EXPORT GBL_RESULT GblAllocationTracker_freeEvent(GBL_SELF, const void *pPtr, GblSourceLocation srcLoc) GBL_NOEXCEPT
To be called every time a free has been requested, to track the event.
GBL_EXPORT GblBool GblAllocationTracker_validatePointer(GBL_CSELF, const void *pPtr) GBL_NOEXCEPT
Returns GBL_TRUE if the given pointer points to an active, tracked allocation.
GBL_EXPORT GBL_RESULT GblAllocationTracker_logActive(GBL_CSELF) GBL_NOEXCEPT
Dumps all of the active allocations and their context information to the log.
GblAllocationCounters counters
Current allocation counters.
GBL_EXPORT GBL_RESULT GblAllocationTracker_destroy(GBL_SELF) GBL_NOEXCEPT
Destroys the given GblAllocation tracker, returning the result.
GBL_EXPORT GblAllocationTracker * GblAllocationTracker_create(GblContext *pCtx) GBL_NOEXCEPT
Creates a GblAllocationTracker and returns a pointer to it.
GBL_EXPORT void GblAllocationTracker_captureCounters(GBL_CSELF, GblAllocationCounters *pCount) GBL_NOEXCEPT
Saves the current value of GblAllocationTracker::counters to the given structure.
size_t maxAllocationSize
Maximum size of a single allocation.
GBL_EXPORT void GblAllocationTracker_diffCounters(GBL_CSELF, const GblAllocationCounters *pSrc, GblAllocationCounters *pDst) GBL_NOEXCEPT
Takes the difference between GblAllocationTracker::counters and pSrc, storing the result in the pDst.
size_t maxAllocations
Maximum number of active allocations.
size_t maxBytes
Maximum number of allocated bytes.
GBL_EXPORT GBL_RESULT GblAllocationTracker_reallocEvent(GBL_SELF, const void *pExisting, const void *pNew, size_t newSize, size_t newAlign, GblSourceLocation srcLoc) GBL_NOEXCEPT
To be called every time a reallocation has been requested, to track the event.