Guis in StarterGui don't GC?

I have noticed that repetitively calling Player:LoadCharacter() (50 times for testing), the GUI section under memory will raise however after waiting minutes later, this does not drop. There are no scripts in the GUI and it has the RestOnSpawn property on. (Note: Most of the frames in the GUI were not made visible in this)

I’m not sure if I’m doing something wrong and my knowledge on garbage collection isn’t much so I won’t post this as a bug report yet.

Result1


Few mins later still the same:

To get around this, I put the GUI in a folder in ReplicatedStorage, and cloned it into PlayerGui with a local script on each Player.CharacterAdded.

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:

Result2

‎‎

Hopefully someone can explain why this is to me.

So when ResetOnSpawn is disabled, is the gui memory stable? and @ArrantNickel Garbage collection is not disabled on roblox.

I haven’t tried with ResetOnSpawn disabled, I will try now.

1 Like

I think it’s a bug, since it doesnt happen to any other instances in other locations which are implicitly removed from the game. This also happens to scripts inside those GUIs. I always see errors due to persisting script connections even though their parent is nil, which makes me believe that Instances in ResetOnSpawn GUIs are not properly removed via implicit :Destroy(). Because of this I always try to avoid having ResetOnRespawn enabled. Never got around to make a bug report on this.

1 Like

After running test:

ResetOnSpawn disabled

ResetOnSpawn enabled

This leads to believe as @NachtHemd has said that ResetOnSpawn GUIs aren’t properly removed with :Destroy().

The only reason I can think this is happening is since your parenting them to PlayerGui each time the character spawns, which is what the ResetOnSpawn property would do, could you do this in studio, and see if the explorer window contains the same gui multiple times. Navigate to Players, your player, playergui and see if it is recreating the same guis multiple times.

No no, the problem is actually fixed by manually parenting them to the PlayerGui each time the character spawns. What I have found is that GUIs with the ResetOnSpawn property enabled in StarterGui cause this.

But you know when it resets on spawn you have to update the reference to the gui, I will test it now.

Like I said, there are no scripts, just the 1 line code of respawning the character to test.

This is 100% a bug on Roblox’s end and you should file a bug report. I just did a test and got the same results. I created screen guis and respawned myself 100 times and the memory went up and persisted even after i stopped resetting.

The spike at the start is when i was resetting and it didn’t go back down after I stopped. Here is the file to reproduce it: ResetOnSpawn Memory Leak.rbxl (29.9 KB)

2 Likes

Just because __gc isn’t available doesn’t mean GC is “99% disabled”–
Conceptually, cleanup is still there, even if the implementation is different, so for objects, a new cleanup
method had to be implemented–Tag-based destructors.

I have seen other reports similar to this–Maybe it’s a bug–Maybe it’s just impatience for when memory
is freed.