The Gui section under ServerMemory\PlaceMemory is insanely high and rises over time. This happens 100% of the time on all my games, in all servers. It seems to be tied to server age (and potentially the amount of instantiated Gui instances?) but doesn’t appear to increase until you rejoin the server. A quick scan of all instances in a live server shows there is nothing that would physically be affecting the memory growth. In some instances, it can be over 500mb.
I have no idea how long this has been going on - only noticed it yesterday. Not sure if this is a display bug. Seems to be tied to performance, however. Does not fix over time or after re-join.
Edit: Until this is fixed, you can run this code on the server to put a band-aid on the leak:
game.Players.PlayerRemoving:Connect(function(player)
pcall(function()
local playerGui = player:FindFirstChild("PlayerGui")
if(playerGui) then
playerGui:ClearAllChildren()
end
end)
end)
Did you really set the parent of the unused instantiated GuiObjects to nil?
I’m going to test something, observing the memory of that and see whether it is from the engine itself or the game only. Will report a result later on.
The majority of that memory was from the Gui category in PlaceMemory. Virtually nothing GUI related is handled on the server in the affected game - other than auto-replication such as StarterGui.
edit:
this is affecting all of my games. 5+ games all experiencing 2000MB+ server side memory.
I am experiencing a similar problem, but on a much larger scale. While there is a billboardgui for every player’s character, I have already ensured that it is getting garbage collected many times. The total server memory is higher than I thought it could even go, so I’m a little confused on that front as well. This screenshot is taken on a server that is around 17.5 hours old.
Edit: I noticed the discrepancy between the total memory and PlaceMemory, upon looking at the other categories I noticed that UntrackedMemory had a fairly large negative value. I am not very experienced with this so I don’t know if this is a bug with the developer console or something else.
We will be releasing a fix for this soon.Now Live 5/30/2019
The technical stuff:
On the server, when a player leaves, the PlayerGui instance will be deparented from the Player instance.
If your game’s scripts currently hold references to the PlayerGui after the Player leaves. You will still be able to access them though the reference you hold from before the player left. However, after the player leaves the game (when the Player is removed from game.Players), the PlayerGui’s parent will be nil, and vice versa, you will not be able to find the PlayerGui instance under Player instance. Also it is important to make sure that the reference held in any server scripts to the PlayerGui is removed. If any server script continues to hold onto the reference of the PlayerGui, the engine will not be able to clean up PlayerGui and its descendants until those references are removed.
If your game’s scripts does not currently hold any references to the PlayerGui of the Player who left, the engine will clean up the PlayerGui and all of its descendant automatically.
This leaking condition does not apply to all games; however, (on similar topic) please take a moment to ensure that server scripts are not left holding a reference to the Player instance for longer than intended. This will cause a slow memory leak of the Player instance and possibly all of its descendants.
Hey KnightTakami.
I have this gui memory leak problem in my game, and I have scanned through all of my server scripts and the PlayerGui isn’t mentioned once, and I’m pretty sure the Player instance isn’t help onto for very long at all. Are there any other possible sources of the leak? And does the leak actually cause any lag on the server? I have cars in my game and they seem to get very laggy the longer the server has been up, so I am just wondering if the gui memory could be causing this?
(only the cars lag - everything else runs fine)