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

Function TickProfilerMemory

Source/Engine/Profiler/ProfilerMemory.cpp:314–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312}
313
314void TickProfilerMemory()
315{
316 // Update .NET GC memory stats
317 int64 totalCommitted, heapSize;
318 MCore::GC::MemoryInfo(totalCommitted, heapSize);
319 int64 gcComittedDelta = totalCommitted - GroupMemory[(int32)ProfilerMemory::Groups::ScriptingCSharpGCCommitted];
320 GroupMemory[(int32)ProfilerMemory::Groups::ScriptingCSharpGCCommitted] = totalCommitted;
321 GroupMemory[(int32)ProfilerMemory::Groups::ScriptingCSharpGCHeap] = heapSize;
322 UPDATE_PEEK(ProfilerMemory::Groups::ScriptingCSharpGCCommitted);
323 UPDATE_PEEK(ProfilerMemory::Groups::ScriptingCSharpGCHeap);
324 Platform::InterlockedAdd(&GroupMemory[(int32)ProfilerMemory::Groups::TotalTracked], gcComittedDelta);
325
326 // Update profiler memory
327 PointersLocker.Lock();
328 GroupMemory[(int32)ProfilerMemory::Groups::Profiler] =
329 sizeof(GroupMemory) + sizeof(GroupNames) + sizeof(GroupStack) +
330#ifdef USE_TRACY_MEMORY_PLOTS
331 sizeof(GroupTracyPlotEnable) +
332#endif
333 Pointers.Capacity() * sizeof(Dictionary<void*, PointerData>::Bucket);
334 PointersLocker.Unlock();
335
336 // Get total system memory and update untracked amount
337 auto memory = Platform::GetProcessMemoryStats();
338 memory.UsedPhysicalMemory -= GroupMemory[(int32)ProfilerMemory::Groups::Profiler];
339 GroupMemory[(int32)ProfilerMemory::Groups::Total] = memory.UsedPhysicalMemory;
340 GroupMemory[(int32)ProfilerMemory::Groups::TotalUntracked] = Math::Max<int64>(memory.UsedPhysicalMemory - GroupMemory[(int32)ProfilerMemory::Groups::TotalTracked], 0);
341
342 // Update peeks
343 UPDATE_PEEK(ProfilerMemory::Groups::Profiler);
344 UPDATE_PEEK(ProfilerMemory::Groups::Total);
345 UPDATE_PEEK(ProfilerMemory::Groups::TotalUntracked);
346 GroupMemoryPeek[(int32)ProfilerMemory::Groups::Total] = Math::Max(GroupMemoryPeek[(int32)ProfilerMemory::Groups::Total], GroupMemoryPeek[(int32)ProfilerMemory::Groups::TotalTracked]);
347}
348
349bool ProfilerMemory::Enabled = false;
350

Callers 1

OnLoopMethod · 0.85

Calls 5

LockMethod · 0.80
UnlockMethod · 0.80
InterlockedAddFunction · 0.50
MaxFunction · 0.50
CapacityMethod · 0.45

Tested by

no test coverage detected