Hey everyone, having a weird issue with qb-menu that I can't figure out. I'm building a vehicle repair system where the menu shows different parts that need fixing, but every time I open/close the menu the memory just keeps climbing.
I'm seeing like 2-3MB added each cycle in the browser tab, and after opening it 20-30 times it gets super laggy and eventually crashes. The performance tab shows the heap just growing consistently and there are these 'Potential memory leak detected' warnings in the console.
Here's basically what my event looks like:
RegisterNetEvent('vehicle:repairMenu', function(vehicleData)
local options = {}
for i = 1, #vehicleData.parts do
-- Each open creates new listeners without cleanup
table.insert(options, {
title = vehicleData.parts[i].name,
icon = 'wrench',
onSelect = function()
-- Creates closure referencing vehicleData
TriggerServerEvent('repair:part', vehicleData.netId, i)
end
})
end
lib.registerContext({id='repair_menu', options=options})
lib.showContext('repair_menu')
end)I'm guessing the closures are holding onto references or something? I know React components need cleanup but I'm not sure how that works with NUI. Any ideas how to properly clear this stuff out when the menu closes?
Using QBCore with latest qb-menu if that matters.
PotatoPC · 30/08/2026
Sign in to reply.