Add missing memory alloc profiling for virtual pages

This commit is contained in:
Wojtek Figat
2025-05-22 04:41:01 +02:00
parent 2dc404cbd3
commit 9215f2662f

View File

@@ -283,14 +283,23 @@ void* Win32Platform::AllocatePages(uint64 numPages, uint64 pageSize)
{
const uint64 numBytes = numPages * pageSize;
#if PLATFORM_UWP
return VirtualAllocFromApp(nullptr, (SIZE_T)numBytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
void* ptr = VirtualAllocFromApp(nullptr, (SIZE_T)numBytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
#else
return VirtualAlloc(nullptr, (SIZE_T)numBytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
void* ptr = VirtualAlloc(nullptr, (SIZE_T)numBytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
#endif
if (!ptr)
OutOfMemory();
#if COMPILE_WITH_PROFILER
OnMemoryAlloc(ptr, size);
#endif
return ptr;
}
void Win32Platform::FreePages(void* ptr)
{
#if COMPILE_WITH_PROFILER
OnMemoryFree(ptr);
#endif
VirtualFree(ptr, 0, MEM_RELEASE);
}