local count = 0
while true do
count += 1
local duiObject = CreateDui('about:blank', 1920, 1080)
print(count)
while not IsDuiAvailable(duiObject) do
Wait(100)
end
Wait(100)
DestroyDui(duiObject)
end
I’m currently developing a farming/plant-growing system. The idea is that when a player gets close to a plant, a DUI is created and displayed for that plant. When the player moves away from the plant, the DUI is destroyed.
This means multiple DUIs can appear at the same time—only for the plants within range—and they are cleaned up when no longer needed. The issue arises when many DUIs are created and destroyed frequently as the player moves around, which seems to lead to performance issues or crashes after a certain point.
The function DestroyDui , as the name suggest should clean up everything about that dui, but some thing i have faced during my usage of DUI specially in cases where DUI is repeated, is that the usage of the DestroyDui does not even destroy the texture that was created by it, and the texture will remain and allocate that specific texture name inside the texture dictionary it was created in until the client closes fivem or the script itself restarts, there is probably more to this than the textures that is causing a severe overhead when using duis repeatedly by creating more and destroying unused ones.
my solution for this problem was instead of destroying we let duis idle until next usage, although with minimal html/css/js load to minimize the cpu/usage of their respective chromium process.
This solution also has problems, sometimes the engine itself destroys some unused duis, although its rare but it happens and the usage of IsDuiAvailable will throw an error instead of false, wrap this around a pcall and you would have a safe IsDuiAvailable to detect this
the DUIs in general have alot of issues that needs to be addressed.
Yes, I’ve already applied the method you suggested to resolve the issue in my system. I’m mainly wondering if, in the future, when a large number of DUIs are created, this problem could still occur or not.