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

Method OnMemoryAlloc

Source/Engine/Platform/Base/PlatformBase.cpp:223–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221#define TRACY_ENABLE_MEMORY (TRACY_ENABLE)
222
223void PlatformBase::OnMemoryAlloc(void* ptr, uint64 size)
224{
225 if (!ptr)
226 return;
227
228#if TEST_MALLOC
229 if (GetMallocTester().OnMalloc(ptr, size))
230 LOG(Fatal, "Invalid malloc detected for pointer 0x{0:x} ({1} bytes)!\n{2}", (uintptr)ptr, size, Platform::GetStackTrace(3));
231#endif
232
233#if TRACY_ENABLE_MEMORY
234 // Track memory allocation in Tracy
235 //tracy::Profiler::MemAlloc(ptr, (size_t)size, false);
236 tracy::Profiler::MemAllocCallstack(ptr, (size_t)size, 12, false);
237#endif
238
239 // Register in memory profiler
240 if (ProfilerMemory::Enabled)
241 ProfilerMemory::OnMemoryAlloc(ptr, size);
242
243 // Register allocation during the current CPU event
244 auto thread = ProfilerCPU::GetCurrentThread();
245 if (thread != nullptr && thread->Buffer.GetCount() != 0)
246 {
247 auto& activeEvent = thread->Buffer.Last().Event();
248 if (activeEvent.End < ZeroTolerance)
249 {
250 activeEvent.NativeMemoryAllocation += (int32)size;
251 }
252 }
253}
254
255void PlatformBase::OnMemoryFree(void* ptr)
256{

Callers

nothing calls this directly

Calls 4

OnMallocMethod · 0.80
EventMethod · 0.80
GetCountMethod · 0.45
LastMethod · 0.45

Tested by

no test coverage detected