Hello, I’ve been made aware of long-term lag on some of my game servers, so I hopped on one of them just to see that the “Gui” memory on the server has been rising overtime without limits. I investigated, and identified the culprit, though now I don’t know why it’s been causing it. I have a leaderboards system on my game and server handles it (creates templates, etc.)
This is the code (culprit), I’ve disabled it by forcing a “if 1 == 1 then continue end” as it’s how I found out it was the one responsible. I am clueless on why the slots still hold memory after being destroyed…
do
local MainFrame = LeaderboardInterface:FindFirstChild("Top100")
local ListFrame = MainFrame:FindFirstChild("ScrollingFrame")
do -- Clear
local ListChildren = ListFrame:GetChildren()
for Index = 1, #ListChildren do
local Slot = ListChildren[Index]
if Slot:IsA("ImageLabel") or Slot:IsA("Frame") then
Slot:Destroy()
end
end
end
for Index = 1, #LeaderboardData do
local Data = LeaderboardData[Index]
local Rank = Index
local Key = tonumber(Data.key)
if Key <= 0 then
continue
end
if 1 == 1 then
continue
end
local Value = BreiferNumberSubUtility.ConvertOrderedDataToNumber(Data.value)
local SlotTemplate = LeaderboardInterfaceAssets:FindFirstChild(Index)
if not SlotTemplate then SlotTemplate = LeaderboardInterfaceAssets:FindFirstChild("Normal") end
local Template = SlotTemplate:Clone()
local DataFrame = Template:FindFirstChild("Data")
local NameFrame = Template:FindFirstChild("Name")
local RankFrame = Template:FindFirstChild("Rank")
local DataLabel = DataFrame:FindFirstChild("Label")
local NameLabel = NameFrame:FindFirstChild("Label")
local RankLabel = RankFrame:FindFirstChild("Label")
if LeaderboardName ~= "MostUsedCodes" then
do
local name = "Failed To Load"
if cachedUserIdName[Key] then
name = cachedUserIdName[Key]
else
local Sucess, PlayerName = pcall(Players.GetNameFromUserIdAsync, Players, Key)
if not Sucess then warn("Failed extraction of key".. Key.. " due to:".. PlayerName) end
if Sucess then
name = PlayerName
cachedUserIdName[Key] = PlayerName
end
end
NameLabel.Text = name
Template.Name = name
end
else
NameLabel.Text = Data.key
end
if TimerLeaderboards[LeaderboardName] then
local TimeData = NumberUtility.ConvertSecondsToTime(Value)
DataLabel.Text = TimeData["Days"].."d "..TimeData["Hours"].."h"
else
DataLabel.Text = BreiferNumberSubUtility.Abbreviate(Value)
end
RankLabel.Text = NumberUtility.AddNumberIdentifier(Rank)
Template.Name = Index
Template.Parent = ListFrame
end
end
``
Thank you!