2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-04-19 01:03:50 -04:00

Manually trigger Lua GC periodically.

This commit is contained in:
Xjph 2022-05-29 21:57:57 -02:30
parent bb9185ef8a
commit 2200b94a6c

View File

@ -13,12 +13,13 @@ namespace Observatory.Explorer
private Lua LuaState; private Lua LuaState;
private List<LuaFunction> CriteriaFunctions; private List<LuaFunction> CriteriaFunctions;
Action<Exception, String> ErrorLogger; Action<Exception, String> ErrorLogger;
private uint ScanCount;
public CustomCriteriaManager(Action<Exception, String> errorLogger) public CustomCriteriaManager(Action<Exception, String> errorLogger)
{ {
ErrorLogger = errorLogger; ErrorLogger = errorLogger;
CriteriaFunctions = new(); CriteriaFunctions = new();
ScanCount = 0;
} }
public void RefreshCriteria(string criteriaPath) public void RefreshCriteria(string criteriaPath)
@ -191,6 +192,7 @@ namespace Observatory.Explorer
public List<(string, string, bool)> CheckInterest(Scan scan, Dictionary<ulong, Dictionary<int, Scan>> scanHistory, Dictionary<ulong, Dictionary<int, FSSBodySignals>> signalHistory, ExplorerSettings settings) public List<(string, string, bool)> CheckInterest(Scan scan, Dictionary<ulong, Dictionary<int, Scan>> scanHistory, Dictionary<ulong, Dictionary<int, FSSBodySignals>> signalHistory, ExplorerSettings settings)
{ {
List<(string, string, bool)> results = new(); List<(string, string, bool)> results = new();
ScanCount++;
foreach (var criteriaFunction in CriteriaFunctions) foreach (var criteriaFunction in CriteriaFunctions)
{ {
@ -255,9 +257,20 @@ namespace Observatory.Explorer
} }
} }
if (ScanCount > 99)
{
ScanCount = 0;
LuaGC();
}
return results; return results;
} }
private void LuaGC()
{
LuaState.DoString("collectgarbage()");
}
internal class Parent internal class Parent
{ {
public string ParentType; public string ParentType;