Description: Gui Memory usage continually increases and never decreases.
Occurs in: All Games using Roblox Player.
Steps to reproduce:
Launch any game that you have published, from the Roblox website.
Open the In-game menu from the top left Roblox icon, and switch to Settings tab
Under Developer Console, click “Open” button (only appears if you own the game)
In Developer Console switch to Memory Tab and drill into Client > Memory > PlaceMemory > Gui
Notice the value always increases and never decreases
Close the Developer Console and return
Notice the value of Gui Memory is always higher
Scroll down to the bottom the list of nodes in the Memory Tab of Developer Console, and back to the top of the list
Notice that by scrolling the list, the memory usage increases faster
Scroll down to the bottom and the top of the list in Developer Console 10 times and notice memory consumption has gone up considerably.
Close the Developer Console and re-open. Notice the Gui Memory is always higher and is never released.
Expected: At some point, Gui memory should be garbage collected. Expect to be able to accurately monitor memory usage of my Experience so that real problems in my code aren’t masked by underlying system instability.
Observed: There appears to be a leak in Gui Memory, causing usage to continually increase.
It does not matter if the Place itself has any Gui features. This can be reproduced with an empty Baseplate.
Heyo, I did some digging in the CoreScripts to find out why this is happening and help any engineers that want to look into this.
The DevConsole’s memory analyzer creates a list of the entries inside the ScrollingFrame (DevConsoleMaster → Entries) using a table called elements on line 251 of RobloxGui.Modules.DevConsole.Components.Memory.MemoryView inside the MemoryView:render() function.
The above function is called whenever you scroll or open the memory analyzer, so that it can update and re-render all of the lists. However, due to this, the function called self:recursiveConstructEntries is passed the elements table to create and fill all of the TextButtons on the CoreGui, this is where the memory leak occurs. The elements table isn’t ever cleared out nor are the previous TextButtons in use destroyed. The reason both LuaHeap and Gui are increasing is because it’s not garbage collecting the TextButtons (Gui) and the elements table is keeping a reference to all of them (LuaHeap).
The solution to fixing this CoreScript memory leak would be to clear the previous elements table every time when rendering by :Destroying the previous buttons and then clearing the table (Before line 266 & 267). This information should help any engineers that want to look into this issue and more easily solve it. This issue has been affecting me and some of my fellow developers as we’d notice our memory usage would drastically increase when simply scrolling the scroll bar up and down really fast.
To anyone else that wants to see the memory leak for yourself, you can play test in Roblox Studio on a baseplate and enable the Show CoreGUI in Explorer option and go to the aforementioned ModuleScript above to find the memory leak cause.
I’ve got around 2GB memory leaks on Studio, even if baseplate has no scripts or plugins being used, causing physics going in slow motion (over-rendered)
I hope this can be resolved quickly. It has been bothering my team for a while now and it’s been 2 weeks since staff have left a reply. My game uses 4gb of memory before it crashes.