In one of my games, I can tell there’s a large memory leak happening related to the PlayerGui. When a player leaves, the UntrackedMemory spikes by ~200 MB, and doesn’t come back down. Now, I know this has been detailed before, HERE, and I’ve tried following steps to meet the criteria to avoid the PlayerGui not getting cleaned up, but the issue persists.
What might I be missing? Does a function like this
function game.ReplicatedStorage.Events.EndRun.OnServerInvoke(Player)
local car = game.Workspace.Cars:FindFirstChild(Player.Name .. "s_Car")
local char = Player.Character
if car ~= nil then
char.Humanoid.Jump = true
car:Destroy()
end
for i, v in pairs(Player.PlayerGui:GetChildren()) do
if v.Name == "TurboGUI" or v.Name == "FlyScript" then
v:Destroy()
end
end
end
Cause a leftover reference to the Player/PlayerGui?