From a971a14d188e7fba1baedebe1c6b53e65f6b7785 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 16 May 2026 17:15:14 -0700 Subject: [PATCH] findAll: defer slips storage order initialization (~20MB RAM savings) The `slips.storages:map()` call at module level iterates every storage slip ID and accesses `res.items[id]` for each, forcing Windower's lazy-loading resource system to materialize a large portion of the item database into memory (~20MB). Defer this initialization to the first `search()` call. The slips order only needs to be built once and is cached for subsequent searches. Cold `res.items[id]` lookups benchmark at ~0.2ms each, so the first search has negligible additional latency. Idle memory drops from ~27MB to ~700KB. For multiboxers running 6+ clients this saves ~150MB+ of RAM across all instances. --- addons/findAll/findAll.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/addons/findAll/findAll.lua b/addons/findAll/findAll.lua index 6a644eafa..8f7feda48 100644 --- a/addons/findAll/findAll.lua +++ b/addons/findAll/findAll.lua @@ -192,12 +192,20 @@ storages_order = S(res.bags:map(string.gsub-{' ', ''} .. string.lower .. return index1 < index2 end) -local storage_slips_order = slips.storages:map(function(id) - return 'slip ' .. res.items[id].english:lower():match('^storage slip (.*)$') -end) -merged_storages_orders = storages_order + storage_slips_order + L{'key items'} +-- Deferred: slips iteration accesses res.items[id] for every slip, materializing +-- a large portion of the item database (~20MB). Build on first search instead. +merged_storages_orders = nil + +local function ensure_merged_storages_orders() + if merged_storages_orders then return end + local storage_slips_order = slips.storages:map(function(id) + return 'slip ' .. res.items[id].english:lower():match('^storage slip (.*)$') + end) + merged_storages_orders = storages_order + storage_slips_order + L{'key items'} +end -function search(query, export) +function search(query, export) + ensure_merged_storages_orders() update_global_storage() update() if query:length() == 0 then