Force GC to run periodically in order to reduce stuttering
This commit is contained in:
@@ -106,6 +106,8 @@ public:
|
||||
{
|
||||
static void Collect();
|
||||
static void Collect(int32 generation);
|
||||
static void Collect(int32 generation, MGCCollectionMode collectionMode, bool blocking, bool compacting);
|
||||
static int32 MaxGeneration();
|
||||
static void WaitForPendingFinalizers();
|
||||
static void WriteRef(void* ptr, MObject* ref);
|
||||
static void WriteValue(void* dst, void* src, int32 count, const MClass* klass);
|
||||
|
||||
@@ -56,6 +56,14 @@ enum class MTypes : uint32
|
||||
Enum = 0x55,
|
||||
};
|
||||
|
||||
enum class MGCCollectionMode
|
||||
{
|
||||
Default = 0,
|
||||
Forced = 1,
|
||||
Optimized = 2,
|
||||
Aggressive = 3
|
||||
};
|
||||
|
||||
#if USE_NETCORE
|
||||
|
||||
enum class MTypeAttributes : uint32;
|
||||
|
||||
@@ -422,19 +422,36 @@ void MCore::GCHandle::Free(const MGCHandle& handle)
|
||||
void MCore::GC::Collect()
|
||||
{
|
||||
PROFILE_CPU();
|
||||
// TODO: call System.GC.Collect()
|
||||
static void* GCCollectPtr = GetStaticMethodPointer(TEXT("GCCollect"));
|
||||
CallStaticMethod<void, int, int, bool, bool>(GCCollectPtr, MaxGeneration(), (int)MGCCollectionMode::Default, true, false);
|
||||
}
|
||||
|
||||
void MCore::GC::Collect(int32 generation)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
// TODO: call System.GC.Collect(int32)
|
||||
static void* GCCollectPtr = GetStaticMethodPointer(TEXT("GCCollect"));
|
||||
CallStaticMethod<void, int, int, bool, bool>(GCCollectPtr, generation, (int)MGCCollectionMode::Default, true, false);
|
||||
}
|
||||
|
||||
void MCore::GC::Collect(int32 generation, MGCCollectionMode collectionMode, bool blocking, bool compacting)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
static void* GCCollectPtr = GetStaticMethodPointer(TEXT("GCCollect"));
|
||||
CallStaticMethod<void, int, int, bool, bool>(GCCollectPtr, generation, (int)collectionMode, blocking, compacting);
|
||||
}
|
||||
|
||||
int32 MCore::GC::MaxGeneration()
|
||||
{
|
||||
static void* GCMaxGenerationPtr = GetStaticMethodPointer(TEXT("GCMaxGeneration"));
|
||||
static int32 maxGeneration = CallStaticMethod<int32>(GCMaxGenerationPtr);
|
||||
return maxGeneration;
|
||||
}
|
||||
|
||||
void MCore::GC::WaitForPendingFinalizers()
|
||||
{
|
||||
PROFILE_CPU();
|
||||
// TODO: call System.GC.WaitForPendingFinalizers()
|
||||
static void* GCWaitForPendingFinalizersPtr = GetStaticMethodPointer(TEXT("GCWaitForPendingFinalizers"));
|
||||
CallStaticMethod<void>(GCWaitForPendingFinalizersPtr);
|
||||
}
|
||||
|
||||
void MCore::GC::WriteRef(void* ptr, MObject* ref)
|
||||
|
||||
@@ -828,6 +828,18 @@ void MCore::GC::Collect(int32 generation)
|
||||
mono_gc_collect(generation);
|
||||
}
|
||||
|
||||
void MCore::GC::Collect(int32 generation, MGCCollectionMode collectionMode, bool blocking, bool compacting)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
mono_gc_collect(generation);
|
||||
}
|
||||
|
||||
int32 MCore::GC::MaxGeneration()
|
||||
{
|
||||
PROFILE_CPU();
|
||||
return mono_gc_max_generation();
|
||||
}
|
||||
|
||||
void MCore::GC::WaitForPendingFinalizers()
|
||||
{
|
||||
PROFILE_CPU();
|
||||
|
||||
@@ -160,6 +160,15 @@ void MCore::GC::Collect(int32 generation)
|
||||
{
|
||||
}
|
||||
|
||||
void MCore::GC::Collect(int32 generation, MGCCollectionMode collectionMode, bool blocking, bool compacting)
|
||||
{
|
||||
}
|
||||
|
||||
int32 MCore::GC::MaxGeneration()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MCore::GC::WaitForPendingFinalizers()
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user