Guis in StarterGui with ResetOnSpawn do not get garbage collected

Having a GUI with ResetOnSpawn enabled placed in StarterGui will cause memory under “Gui” to keep raising each time the character is respawned and will not lower.

Result1


Few mins later still the same:



Here is a quick alternative to getting around this that I did: I put the GUI in a folder in ReplicatedStorage, and cloned it into PlayerGui with a local script on each Player.CharacterAdded (place in StarterPlayerScripts).

Code
local plr = game.Players.LocalPlayer

    plr.CharacterAdded:Connect(function()
    	for _,v in pairs(game.ReplicatedStorage.Folder:GetChildren()) do
    		v:Clone().Parent = plr.PlayerGui
    	end
    end)

This was the result I got, which shows that the original problem is most definitely caused by StarterGui and how it handles the ResetOnSpawn:

Result2

Repro: ResetOnSpawn Memory Leak.rbxl (29.9 KB)

4 Likes

May be related:

3 Likes

@PeZsmistic thanks for referencing this! It’s possible that this issue may be slightly different since this leak appears to happen on respawn (as opposed to the leak you posted, which appears to occur when the player leaves the game).

4 Likes

@RVVZ thank you for the report! I’ve assigned a ticket to investigate.

3 Likes