Removes PlatformMemoryInstrumentation.h and PLATFORM_MEMORY_INSTRUMENTATION_ENABLED

This was part of another instrumentation framework that was never fully integrated

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-12-01 18:47:23 -08:00
parent 3f6246ccbe
commit 075eeee0bd
4 changed files with 0 additions and 74 deletions
@@ -73,30 +73,23 @@ void AllocatorBase::PostCreate()
}
}
#if PLATFORM_MEMORY_INSTRUMENTATION_ENABLED
m_platformMemoryInstrumentationGroupId = AZ::PlatformMemoryInstrumentation::GetNextGroupId();
AZ::PlatformMemoryInstrumentation::RegisterGroup(m_platformMemoryInstrumentationGroupId, GetDescription(), AZ::PlatformMemoryInstrumentation::m_groupRoot);
#else
const auto debugConfig = GetDebugConfig();
if (!debugConfig.m_excludeFromDebugging)
{
SetRecords(aznew Debug::AllocationRecords((unsigned char)debugConfig.m_stackRecordLevels, debugConfig.m_usesMemoryGuards, debugConfig.m_marksUnallocatedMemory, GetName()));
}
#endif
m_isReady = true;
}
void AllocatorBase::PreDestroy()
{
#if !PLATFORM_MEMORY_INSTRUMENTATION_ENABLED
Debug::AllocationRecords* allocatorRecords = GetRecords();
if(allocatorRecords)
{
delete allocatorRecords;
SetRecords(nullptr);
}
#endif
if (m_registrationEnabled && AZ::AllocatorManager::IsReady())
{
@@ -144,15 +137,11 @@ void AllocatorBase::ProfileAllocation(void* ptr, size_t byteSize, size_t alignme
if (m_isProfilingActive)
{
#if PLATFORM_MEMORY_INSTRUMENTATION_ENABLED
AZ::PlatformMemoryInstrumentation::Alloc(ptr, byteSize, 0, m_platformMemoryInstrumentationGroupId);
#else
auto records = GetRecords();
if (records)
{
records->RegisterAllocation(ptr, byteSize, alignment, name, fileName, lineNum, suppressStackRecord + 1);
}
#endif
}
}
@@ -160,39 +149,25 @@ void AllocatorBase::ProfileDeallocation(void* ptr, size_t byteSize, size_t align
{
if (m_isProfilingActive)
{
#if PLATFORM_MEMORY_INSTRUMENTATION_ENABLED
AZ::PlatformMemoryInstrumentation::Free(ptr);
#else
auto records = GetRecords();
if (records)
{
records->UnregisterAllocation(ptr, byteSize, alignment, info);
}
#endif
}
}
void AllocatorBase::ProfileReallocationBegin([[maybe_unused]] void* ptr, [[maybe_unused]] size_t newSize)
{
if (m_isProfilingActive)
{
#if PLATFORM_MEMORY_INSTRUMENTATION_ENABLED
AZ::PlatformMemoryInstrumentation::ReallocBegin(ptr, newSize, m_platformMemoryInstrumentationGroupId);
#endif
}
}
void AllocatorBase::ProfileReallocationEnd(void* ptr, void* newPtr, size_t newSize, size_t newAlignment)
{
if (m_isProfilingActive)
{
#if PLATFORM_MEMORY_INSTRUMENTATION_ENABLED
AZ::PlatformMemoryInstrumentation::ReallocEnd(newPtr, newSize, 0);
#else
Debug::AllocationInfo info;
ProfileDeallocation(ptr, 0, 0, &info);
ProfileAllocation(newPtr, newSize, newAlignment, info.m_name, info.m_fileName, info.m_lineNum, 0);
#endif
}
}
@@ -205,13 +180,11 @@ void AllocatorBase::ProfileResize(void* ptr, size_t newSize)
{
if (newSize && m_isProfilingActive)
{
#if !PLATFORM_MEMORY_INSTRUMENTATION_ENABLED
auto records = GetRecords();
if (records)
{
records->ResizeAllocation(ptr, newSize);
}
#endif
}
}
@@ -8,7 +8,6 @@
#pragma once
#include <AzCore/Memory/IAllocator.h>
#include <AzCore/Memory/PlatformMemoryInstrumentation.h>
namespace AZ
{
@@ -110,9 +109,6 @@ namespace AZ
bool m_isReady = false;
bool m_canBeOverridden = true;
bool m_registrationEnabled = true;
#if PLATFORM_MEMORY_INSTRUMENTATION_ENABLED
uint16_t m_platformMemoryInstrumentationGroupId = 0;
#endif
};
namespace Internal {
@@ -1,42 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/AzCore_Traits_Platform.h>
#if AZ_TRAIT_OS_MEMORY_INSTRUMENTATION && !defined(_RELEASE)
#define PLATFORM_MEMORY_INSTRUMENTATION_ENABLED 1
#else
#define PLATFORM_MEMORY_INSTRUMENTATION_ENABLED 0
#endif
#if PLATFORM_MEMORY_INSTRUMENTATION_ENABLED
#include <AzCore/base.h>
#include <AzCore/std/parallel/mutex.h>
namespace AZ
{
/**
* PlatformMemoryInstrumentation - Abstraction layer for platform specific memory instrumentation.
*/
class PlatformMemoryInstrumentation
{
public:
static uint16_t GetNextGroupId() { return m_nextGroupId++; };
static void RegisterGroup(uint16_t id, const char* name, uint16_t parentGroup);
static void Alloc(const void* ptr, uint64_t size, uint32_t padding, uint16_t group);
static void Free(const void* ptr);
static void ReallocBegin(const void* origPtr, uint64_t size, uint16_t group);
static void ReallocEnd(const void* newPtr, uint64_t size, uint32_t padding);
static const uint16_t m_groupRoot;
static uint16_t m_nextGroupId;
};
}
#endif // PLATFORM_MEMORY_INSTRUMENTATION_ENABLED
@@ -406,7 +406,6 @@ set(FILES
Memory/OSAllocator.h
Memory/OverrunDetectionAllocator.cpp
Memory/OverrunDetectionAllocator.h
Memory/PlatformMemoryInstrumentation.h
Memory/PoolAllocator.h
Memory/PoolSchema.cpp
Memory/PoolSchema.h