Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::MemoryTracker Namespace Reference

Classes

struct  AllocationInfo
 Struct to hold memory allocation information. More...

Functions

void AddAllocation (void *ptr, usize size, const char *function)
 Mutex for thread-safety when accessing the allocation map.
void RemoveAllocation (void *ptr)
 Remove a memory allocation from the tracker.
void DumpLeaks ()
 Dump memory leaks, if any.

Variables

std::unordered_map< void *, AllocationInfos_Allocations
std::mutex s_Mutex
 Global map tracking allocations.

Function Documentation

◆ AddAllocation()

void Raven::MemoryTracker::AddAllocation ( void * ptr,
usize size,
const char * function )
inline

Mutex for thread-safety when accessing the allocation map.

Add a memory allocation to the tracker.

Adds information about an allocated memory block to the global memory tracker.

Parameters
ptrPointer to the allocated memory.
sizeSize of the allocated memory in bytes.
functionThe function from which the allocation was made.

◆ DumpLeaks()

void Raven::MemoryTracker::DumpLeaks ( )
inline

Dump memory leaks, if any.

Logs any memory that was allocated but not freed, indicating potential memory leaks.

◆ RemoveAllocation()

void Raven::MemoryTracker::RemoveAllocation ( void * ptr)
inline

Remove a memory allocation from the tracker.

Removes the given memory allocation from the tracker and logs the deallocation.

Parameters
ptrPointer to the memory being freed.

Variable Documentation

◆ s_Allocations

std::unordered_map<void*, AllocationInfo> Raven::MemoryTracker::s_Allocations
inline

◆ s_Mutex

std::mutex Raven::MemoryTracker::s_Mutex
inline

Global map tracking allocations.