in ransomware/artifact.lua [2095:2128]
function GarbageCollect()
utils.DebugLog('*** GarbageCollect INVOKED')
utils.DebugLog('[lua] Current Memory Usage: ' .. collectgarbage('count'))
local totalPidsToNil = 0
for _, v1 in pairs(globals.namespaces) do
globals.SwitchNamespace(v1)
local pidsToNil = {}
for k2, v2 in pairs(globals.namespace.processDataTable) do
utils.DebugLog('[lua] PID: ' .. k2)
utils.DebugLog('[lua] totalScore: ' .. v2.totalScore)
utils.DebugLog('[lua] Number events: ' .. #v2.events)
if #v2.events >= globals.PROCESS_EVENT_THRESHOLD then
utils.DebugLog('[lua] Blow away this PID: ' .. k2)
table.insert(pidsToNil, k2)
totalPidsToNil = totalPidsToNil + 1
end
end
for _, v2 in pairs(pidsToNil) do
globals.namespace.processDataTable[v2] = nil
end
end
if totalPidsToNil > 0 then
collectgarbage()
utils.DebugLog('[lua] Cleaned Up Memory Usage: ' .. collectgarbage('count'))
end
return true
end