| 312 | } |
| 313 | |
| 314 | void 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 | |
| 349 | bool ProfilerMemory::Enabled = false; |
| 350 | |