MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / OnMemoryAlloc

Method OnMemoryAlloc

Source/Engine/Profiler/ProfilerMemory.cpp:430–454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

428}
429
430void ProfilerMemory::OnMemoryAlloc(void* ptr, uint64 size)
431{
432 ASSERT_LOW_LAYER(Enabled && ptr);
433 auto& stack = GetGroupStack();
434 if (stack.SkipRecursion)
435 return;
436 stack.SkipRecursion = true;
437
438 // Register pointer
439 PointerData ptrData;
440 ptrData.Size = (uint32)size;
441 ptrData.Group = (uint8)stack.Peek();
442 PointersLocker.Lock();
443 Pointers[ptr] = ptrData;
444 PointersLocker.Unlock();
445
446 // Update group memory
447 const int64 add = (int64)size;
448 AddGroupMemory((Groups)ptrData.Group, add);
449 Platform::InterlockedAdd(&GroupMemory[(int32)Groups::Malloc], add);
450 Platform::InterlockedIncrement(&GroupMemoryCount[(int32)Groups::Malloc]);
451 UPDATE_PEEK(ProfilerMemory::Groups::Malloc);
452
453 stack.SkipRecursion = false;
454}
455
456void ProfilerMemory::OnMemoryFree(void* ptr)
457{

Callers

nothing calls this directly

Calls 6

AddGroupMemoryFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
InterlockedAddFunction · 0.50
InterlockedIncrementFunction · 0.50
PeekMethod · 0.45

Tested by

no test coverage detected