Add more memory profiling insights and groups
This commit is contained in:
@@ -763,7 +763,7 @@ ManagedBinaryModule* ManagedBinaryModule::GetModule(const MAssembly* assembly)
|
||||
|
||||
ScriptingObject* ManagedBinaryModule::ManagedObjectSpawn(const ScriptingObjectSpawnParams& params)
|
||||
{
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
|
||||
// Create native object
|
||||
ScriptingTypeHandle managedTypeHandle = params.Type;
|
||||
@@ -935,7 +935,7 @@ void ManagedBinaryModule::OnLoaded(MAssembly* assembly)
|
||||
{
|
||||
#if !COMPILE_WITHOUT_CSHARP
|
||||
PROFILE_CPU();
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
ASSERT(ClassToTypeIndex.IsEmpty());
|
||||
ScopeLock lock(Locker);
|
||||
|
||||
@@ -1032,7 +1032,7 @@ void ManagedBinaryModule::InitType(MClass* mclass)
|
||||
const StringAnsiView typeName = mclass->GetFullName();
|
||||
if (TypeNameToTypeIndex.ContainsKey(typeName))
|
||||
return;
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
|
||||
// Find first native base C++ class of this C# class
|
||||
MClass* baseClass = mclass->GetBaseClass();
|
||||
@@ -1192,7 +1192,7 @@ void ManagedBinaryModule::OnUnloading(MAssembly* assembly)
|
||||
void ManagedBinaryModule::OnUnloaded(MAssembly* assembly)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
|
||||
// Clear managed-only types
|
||||
Types.Resize(_firstManagedTypeIndex);
|
||||
|
||||
@@ -92,7 +92,7 @@ bool MAssembly::Load(const String& assemblyPath, const StringView& nativePath)
|
||||
if (IsLoaded())
|
||||
return false;
|
||||
PROFILE_CPU();
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
ZoneText(*assemblyPath, assemblyPath.Length());
|
||||
Stopwatch stopwatch;
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ public:
|
||||
static void Collect(int32 generation);
|
||||
static void Collect(int32 generation, MGCCollectionMode collectionMode, bool blocking, bool compacting);
|
||||
static int32 MaxGeneration();
|
||||
static void MemoryInfo(int64& totalCommitted, int64& heapSize);
|
||||
static void WaitForPendingFinalizers();
|
||||
static void WriteRef(void* ptr, MObject* ref);
|
||||
static void WriteValue(void* dst, void* src, int32 count, const MClass* klass);
|
||||
|
||||
@@ -282,7 +282,7 @@ void MCore::UnloadDomain(const StringAnsi& domainName)
|
||||
bool MCore::LoadEngine()
|
||||
{
|
||||
PROFILE_CPU();
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
|
||||
// Initialize hostfxr
|
||||
if (InitHostfxr())
|
||||
@@ -550,6 +550,12 @@ int32 MCore::GC::MaxGeneration()
|
||||
return maxGeneration;
|
||||
}
|
||||
|
||||
void MCore::GC::MemoryInfo(int64& totalCommitted, int64& heapSize)
|
||||
{
|
||||
static void* GCMemoryInfoPtr = GetStaticMethodPointer(TEXT("GCMemoryInfo"));
|
||||
CallStaticMethod<void, int64*, int64*>(GCMemoryInfoPtr, &totalCommitted, &heapSize);
|
||||
}
|
||||
|
||||
void MCore::GC::WaitForPendingFinalizers()
|
||||
{
|
||||
PROFILE_CPU();
|
||||
@@ -737,7 +743,7 @@ const MAssembly::ClassesDictionary& MAssembly::GetClasses() const
|
||||
if (_hasCachedClasses || !IsLoaded())
|
||||
return _classes;
|
||||
PROFILE_CPU();
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
Stopwatch stopwatch;
|
||||
|
||||
#if TRACY_ENABLE
|
||||
@@ -800,7 +806,7 @@ void GetAssemblyName(void* assemblyHandle, StringAnsi& name, StringAnsi& fullnam
|
||||
|
||||
DEFINE_INTERNAL_CALL(void) NativeInterop_CreateClass(NativeClassDefinitions* managedClass, void* assemblyHandle)
|
||||
{
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
ScopeLock lock(BinaryModule::Locker);
|
||||
MAssembly* assembly = GetAssembly(assemblyHandle);
|
||||
if (assembly == nullptr)
|
||||
@@ -836,7 +842,7 @@ bool MAssembly::LoadCorlib()
|
||||
if (IsLoaded())
|
||||
return false;
|
||||
PROFILE_CPU();
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
#if TRACY_ENABLE
|
||||
const StringAnsiView name("Corlib");
|
||||
ZoneText(*name, name.Length());
|
||||
@@ -1060,7 +1066,7 @@ const Array<MMethod*, ArenaAllocation>& MClass::GetMethods() const
|
||||
{
|
||||
if (_hasCachedMethods)
|
||||
return _methods;
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
ScopeLock lock(BinaryModule::Locker);
|
||||
if (_hasCachedMethods)
|
||||
return _methods;
|
||||
@@ -1099,7 +1105,7 @@ const Array<MField*, ArenaAllocation>& MClass::GetFields() const
|
||||
{
|
||||
if (_hasCachedFields)
|
||||
return _fields;
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
ScopeLock lock(BinaryModule::Locker);
|
||||
if (_hasCachedFields)
|
||||
return _fields;
|
||||
@@ -1126,7 +1132,7 @@ const Array<MEvent*, ArenaAllocation>& MClass::GetEvents() const
|
||||
{
|
||||
if (_hasCachedEvents)
|
||||
return _events;
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
|
||||
// TODO: implement MEvent in .NET
|
||||
|
||||
@@ -1149,7 +1155,7 @@ const Array<MProperty*, ArenaAllocation>& MClass::GetProperties() const
|
||||
{
|
||||
if (_hasCachedProperties)
|
||||
return _properties;
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
ScopeLock lock(BinaryModule::Locker);
|
||||
if (_hasCachedProperties)
|
||||
return _properties;
|
||||
@@ -1176,7 +1182,7 @@ const Array<MClass*, ArenaAllocation>& MClass::GetInterfaces() const
|
||||
{
|
||||
if (_hasCachedInterfaces)
|
||||
return _interfaces;
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
ScopeLock lock(BinaryModule::Locker);
|
||||
if (_hasCachedInterfaces)
|
||||
return _interfaces;
|
||||
@@ -1216,7 +1222,7 @@ const Array<MObject*, ArenaAllocation>& MClass::GetAttributes() const
|
||||
{
|
||||
if (_hasCachedAttributes)
|
||||
return _attributes;
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
ScopeLock lock(BinaryModule::Locker);
|
||||
if (_hasCachedAttributes)
|
||||
return _attributes;
|
||||
@@ -1401,7 +1407,7 @@ const Array<MObject*, ArenaAllocation>& MField::GetAttributes() const
|
||||
{
|
||||
if (_hasCachedAttributes)
|
||||
return _attributes;
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
ScopeLock lock(BinaryModule::Locker);
|
||||
if (_hasCachedAttributes)
|
||||
return _attributes;
|
||||
@@ -1467,7 +1473,7 @@ void MMethod::CacheSignature() const
|
||||
ScopeLock lock(BinaryModule::Locker);
|
||||
if (_hasCachedSignature)
|
||||
return;
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
|
||||
static void* GetMethodReturnTypePtr = GetStaticMethodPointer(TEXT("GetMethodReturnType"));
|
||||
static void* GetMethodParameterTypesPtr = GetStaticMethodPointer(TEXT("GetMethodParameterTypes"));
|
||||
@@ -1568,7 +1574,7 @@ const Array<MObject*, ArenaAllocation>& MMethod::GetAttributes() const
|
||||
{
|
||||
if (_hasCachedAttributes)
|
||||
return _attributes;
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
ScopeLock lock(BinaryModule::Locker);
|
||||
if (_hasCachedAttributes)
|
||||
return _attributes;
|
||||
@@ -1658,7 +1664,7 @@ const Array<MObject*, ArenaAllocation>& MProperty::GetAttributes() const
|
||||
{
|
||||
if (_hasCachedAttributes)
|
||||
return _attributes;
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
ScopeLock lock(BinaryModule::Locker);
|
||||
if (_hasCachedAttributes)
|
||||
return _attributes;
|
||||
@@ -1689,7 +1695,7 @@ MClass* GetOrCreateClass(MType* typeHandle)
|
||||
{
|
||||
if (!typeHandle)
|
||||
return nullptr;
|
||||
PROFILE_MEM(Scripting);
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
ScopeLock lock(BinaryModule::Locker);
|
||||
MClass* klass;
|
||||
if (!CachedClassHandles.TryGet(typeHandle, klass))
|
||||
@@ -1911,6 +1917,7 @@ void* GetStaticMethodPointer(StringView methodName)
|
||||
if (CachedFunctions.TryGet(methodName, fun))
|
||||
return fun;
|
||||
PROFILE_CPU();
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
const int rc = get_function_pointer(NativeInteropTypeName, FLAX_CORECLR_STRING(methodName).Get(), UNMANAGEDCALLERSONLY_METHOD, nullptr, nullptr, &fun);
|
||||
if (rc != 0)
|
||||
LOG(Fatal, "Failed to get unmanaged function pointer for method '{0}': 0x{1:x}", methodName, (unsigned int)rc);
|
||||
@@ -2278,6 +2285,7 @@ void* GetStaticMethodPointer(StringView methodName)
|
||||
if (CachedFunctions.TryGet(methodName, fun))
|
||||
return fun;
|
||||
PROFILE_CPU();
|
||||
PROFILE_MEM(ScriptingCSharp);
|
||||
|
||||
static MonoClass* nativeInteropClass = nullptr;
|
||||
if (!nativeInteropClass)
|
||||
|
||||
@@ -864,6 +864,11 @@ int32 MCore::GC::MaxGeneration()
|
||||
return mono_gc_max_generation();
|
||||
}
|
||||
|
||||
void MCore::GC::MemoryInfo(int64& totalCommitted, int64& heapSize)
|
||||
{
|
||||
totalCommitted = heapSize = 0;
|
||||
}
|
||||
|
||||
void MCore::GC::WaitForPendingFinalizers()
|
||||
{
|
||||
PROFILE_CPU();
|
||||
|
||||
@@ -190,6 +190,11 @@ int32 MCore::GC::MaxGeneration()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MCore::GC::MemoryInfo(int64& totalCommitted, int64& heapSize)
|
||||
{
|
||||
totalCommitted = heapSize = 0;
|
||||
}
|
||||
|
||||
void MCore::GC::WaitForPendingFinalizers()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -617,6 +617,7 @@ bool Scripting::Load()
|
||||
void Scripting::Release()
|
||||
{
|
||||
PROFILE_CPU();
|
||||
PROFILE_MEM(Scripting);
|
||||
// Note: this action can be called from main thread (due to Mono problems with assemblies actions from other threads)
|
||||
ASSERT(IsInMainThread());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user