Fix: expand table pooling across modules to reduce garbage collection

This commit is contained in:
Bluewhale1337
2026-09-13 20:09:46 +02:00
parent 27ba0a386e
commit 7beff1c4ca
8 changed files with 21 additions and 9 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
## Interface: 11200 ## Interface: 11200
## Title: HealBotBlue ## Title: HealBotBlue
## Version: 1.7.2 ## Version: 1.7.3
## Author: Bluewhale ## Author: Bluewhale
## Notes: Raidframe replacement for healing, decursing, resource tracking and buffing with optional support for SuperWow, ClassicAPI, UnitXP_SP3 and Nampower. ## Notes: Raidframe replacement for healing, decursing, resource tracking and buffing with optional support for SuperWow, ClassicAPI, UnitXP_SP3 and Nampower.
## SavedVariablesPerCharacter: HealBot_Config ## SavedVariablesPerCharacter: HealBot_Config
+4 -2
View File
@@ -136,9 +136,10 @@ end
-- HealBot_SplitString: Internal utility: HealBot_SplitString -- HealBot_SplitString: Internal utility: HealBot_SplitString
function HealBot_SplitString(str, delimiter) function HealBot_SplitString(str, delimiter)
local result = {} local result = HealBot_GetTable()
if not delimiter or delimiter == "" then if not delimiter or delimiter == "" then
return {str} table.insert(result, str)
return result
end end
local start_pos = 1 local start_pos = 1
while true do while true do
@@ -160,6 +161,7 @@ function HealBot_RunMacroText(body)
ChatFrameEditBox:SetText(commands[i]) ChatFrameEditBox:SetText(commands[i])
ChatEdit_SendText(ChatFrameEditBox) ChatEdit_SendText(ChatFrameEditBox)
end end
HealBot_ReleaseTable(commands)
end end
-- HealBot_RunMacro: Internal utility: HealBot_RunMacro -- HealBot_RunMacro: Internal utility: HealBot_RunMacro
+2 -1
View File
@@ -184,7 +184,7 @@ function HealBot_OnEvent_UnitAura(this, unit)
local iconCount = 0 local iconCount = 0
local i = 1; local i = 1;
HealBot_UnitDebuff[unit] = nil; HealBot_UnitDebuff[unit] = nil;
local trackedTextures = {} local trackedTextures = HealBot_GetTable()
while true do while true do
local debuff, tmp, debuff_type = UnitDebuff(unit, i, 1) local debuff, tmp, debuff_type = UnitDebuff(unit, i, 1)
@@ -301,5 +301,6 @@ function HealBot_OnEvent_UnitAura(this, unit)
-- Defer UI updates -- Defer UI updates
HealBot_View_DirtyUnits[unit] = true HealBot_View_DirtyUnits[unit] = true
HealBot_ReleaseTable(trackedTextures)
end end
end end
+2 -1
View File
@@ -472,7 +472,7 @@ function HealBot_FindHealSpells()
end end
end); end);
local items = {}; local items = HealBot_GetTable();
for bag = 0, NUM_BAG_FRAMES do for bag = 0, NUM_BAG_FRAMES do
for slot = 1, GetContainerNumSlots(bag) do for slot = 1, GetContainerNumSlots(bag) do
local item = HealBot_GetItemName(bag, slot); local item = HealBot_GetItemName(bag, slot);
@@ -498,6 +498,7 @@ function HealBot_FindHealSpells()
HealBot_Heals["raidpet" .. i] = HealBot_Heals.party; HealBot_Heals["raidpet" .. i] = HealBot_Heals.party;
end end
HealBot_ReleaseTable(items);
if HealBot_CalcEquipBonus then if HealBot_CalcEquipBonus then
HealBot_AddDebug("...Done Equip Bonus:" .. RealHealing); HealBot_AddDebug("...Done Equip Bonus:" .. RealHealing);
end end
+5 -2
View File
@@ -44,7 +44,7 @@ function HealBot_Integrations_Toggle()
if not spellName then return end if not spellName then return end
if not HealBot_Nampower_Auras[target] then if not HealBot_Nampower_Auras[target] then
HealBot_Nampower_Auras[target] = {} HealBot_Nampower_Auras[target] = HealBot_GetTable()
end end
local expirationTime = GetTime() + (duration / 1000) local expirationTime = GetTime() + (duration / 1000)
@@ -61,7 +61,8 @@ function HealBot_Integrations_Toggle()
HealBot_Integrations_Nampower_Active = false; HealBot_Integrations_Nampower_Active = false;
HealBot_AddDebug("nampower Integration: DISABLED"); HealBot_AddDebug("nampower Integration: DISABLED");
if HealBot_Nampower_Auras then if HealBot_Nampower_Auras then
for k in pairs(HealBot_Nampower_Auras) do for k, v in pairs(HealBot_Nampower_Auras) do
HealBot_ReleaseTable(v)
HealBot_Nampower_Auras[k] = nil HealBot_Nampower_Auras[k] = nil
end end
end end
@@ -76,6 +77,7 @@ function HealBot_Integrations_PruneNampower()
for targetName, auras in pairs(HealBot_Nampower_Auras) do for targetName, auras in pairs(HealBot_Nampower_Auras) do
-- Check if target is still in the raid/party -- Check if target is still in the raid/party
if not HealBot_Model:GetUnitIDByName(targetName) then if not HealBot_Model:GetUnitIDByName(targetName) then
HealBot_ReleaseTable(auras)
HealBot_Nampower_Auras[targetName] = nil HealBot_Nampower_Auras[targetName] = nil
else else
-- Prune expired auras -- Prune expired auras
@@ -88,6 +90,7 @@ function HealBot_Integrations_PruneNampower()
end end
end end
if not hasAuras then if not hasAuras then
HealBot_ReleaseTable(auras)
HealBot_Nampower_Auras[targetName] = nil HealBot_Nampower_Auras[targetName] = nil
end end
end end
+2 -1
View File
@@ -245,7 +245,8 @@ function HealBot_Model:PreserveStateByGUID()
for targetUnit, stateData in pairs(stateSwaps) do for targetUnit, stateData in pairs(stateSwaps) do
-- Deep copy to prevent memory aliasing -- Deep copy to prevent memory aliasing
if not self.units[targetUnit] then if not self.units[targetUnit] then
self.units[targetUnit] = { icons = {} } self.units[targetUnit] = HealBot_GetTable()
self.units[targetUnit].icons = HealBot_GetTable()
end end
local targetIcons = self.units[targetUnit].icons local targetIcons = self.units[targetUnit].icons
+2 -1
View File
@@ -1153,7 +1153,7 @@ end
function HealBot_Action_AppendNewUnits() function HealBot_Action_AppendNewUnits()
if not HealBot_Grid_LastI then return end if not HealBot_Grid_LastI then return end
local unitsToCheck = {} local unitsToCheck = HealBot_GetTable()
-- Gather units based on config, similar to PartyChanged -- Gather units based on config, similar to PartyChanged
if HealBot_Config.GroupHeals == 1 then if HealBot_Config.GroupHeals == 1 then
@@ -1220,4 +1220,5 @@ function HealBot_Action_AppendNewUnits()
HealBot_Action_AppendUnit(unit) HealBot_Action_AppendUnit(unit)
end end
end end
HealBot_ReleaseTable(unitsToCheck)
end end
+3
View File
@@ -49,6 +49,9 @@ Default installation path: `C:\Program Files\World of Warcraft\Interface\AddOns\
### Change Log ### Change Log
**v1.7.3**
* **Performance Fix - Table Pooling Part 2** - Fixed remaining un-pooled table allocations in layout updates, macro parsing, nampower integration, and aura tracking by utilizing HealBot_GetTable().
**v1.7.2** **v1.7.2**
* **Performance Fix - Table Pooling** - Fixed massive Vanilla Lua 5.0 garbage collection memory leaks caused by unbounded table allocations in high-frequency update loops (e.g., `OnUpdate` and `PreserveStateByGUID`). Moved tables to file-local scope and implemented inline clearing. * **Performance Fix - Table Pooling** - Fixed massive Vanilla Lua 5.0 garbage collection memory leaks caused by unbounded table allocations in high-frequency update loops (e.g., `OnUpdate` and `PreserveStateByGUID`). Moved tables to file-local scope and implemented inline clearing.
* **Performance Fix - OOC Cleanup** - Added an out-of-combat garbage collection hook (`PLAYER_REGEN_ENABLED`) to purge disconnected senders from the `HealBot_IncomingHealers` global table, preventing memory bloat during prolonged play sessions. * **Performance Fix - OOC Cleanup** - Added an out-of-combat garbage collection hook (`PLAYER_REGEN_ENABLED`) to purge disconnected senders from the `HealBot_IncomingHealers` global table, preventing memory bloat during prolonged play sessions.