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

Method OnMemoryFree

Source/Engine/Profiler/ProfilerMemory.cpp:456–484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

454}
455
456void ProfilerMemory::OnMemoryFree(void* ptr)
457{
458 ASSERT_LOW_LAYER(Enabled && ptr);
459 auto& stack = GetGroupStack();
460 if (stack.SkipRecursion)
461 return;
462 stack.SkipRecursion = true;
463
464 // Find and remove pointer
465 PointerData ptrData;
466 PointersLocker.Lock();
467 auto it = Pointers.Find(ptr);
468 bool found = it.IsNotEnd();
469 if (found)
470 ptrData = it->Value;
471 Pointers.Remove(it);
472 PointersLocker.Unlock();
473
474 if (found)
475 {
476 // Update group memory
477 const int64 add = -(int64)ptrData.Size;
478 SubGroupMemory((Groups)ptrData.Group, add);
479 Platform::InterlockedAdd(&GroupMemory[(int32)Groups::Malloc], add);
480 Platform::InterlockedDecrement(&GroupMemoryCount[(int32)Groups::Malloc]);
481 }
482
483 stack.SkipRecursion = false;
484}
485
486void ProfilerMemory::OnGroupUpdate(Groups group, int64 sizeDelta, int64 countDelta)
487{

Callers

nothing calls this directly

Calls 8

SubGroupMemoryFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
InterlockedAddFunction · 0.50
InterlockedDecrementFunction · 0.50
FindMethod · 0.45
IsNotEndMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected