Hello, as I was testing my game and modifying my main script, in several of my tests I had observed that the memory usage was over 1GB, around 1.3K MB above the target limit imposed. After disabling certain scripts/objects that consumed an excess of memory, around 700 MB was deducted from the over-all memory consumption. As far as I know, my game only runs on one script with 73 lines of code (including comments), and only four loops, yet both LuaHeap and Script seem to be contributing to the mass of consumption of PlaceMemory. Is there any way why the client is receivng this much memory from just one script?
P.S. There are tools with sounds and animations, however the scripts that run them have been disabled, and Animation’s MB consumption amounts to around 280 MB.
The client’s performance stats for reference:
PlaceMemory under client:
The script:
local Colors = {
"Bright red",
"New Yeller",
"Pine Cone",
"Gold",
"Institutional White"
}
local shelves = game:GetService("Workspace").Shelves:GetChildren()
for _, shelf in ipairs(shelves) do
---
local ItemDisplay = shelf:FindFirstChild("ItemsDisplay").BillboardGui.Frame.TextLabel --Item Display UI
local itemCapacity = #shelf:FindFirstChild("Items"):GetChildren()
local itemsLeft = shelf:FindFirstChild("ItemsLeft")
itemsLeft.Value = itemCapacity
ItemDisplay.Text = itemsLeft.Value.."/"..itemCapacity
print(itemCapacity)
itemsLeft:GetPropertyChangedSignal("Value"):Connect(function()
ItemDisplay.Text = itemsLeft.Value.."/"..itemCapacity
end)
---
local clickParts = shelf.Click:GetDescendants()
-- Shelf deletion by player
for i,v in ipairs(clickParts) do
if v:IsA("ClickDetector") then
v.MouseClick:connect(function(playerWhoClicked)
local itemsTable = v.Parent.Parent.Parent:FindFirstChild("Items"):GetChildren()
if #itemsTable == 0 then
return
end
local itemToBeDestroyed = itemsTable[math.random(1, #itemsTable)]
table.remove(itemsTable, i)
itemToBeDestroyed:Destroy()
itemsLeft.Value -=1
print(#itemsTable)
--Cloning to player's backpack
local itemCloneTable = game:GetService("ServerStorage"):FindFirstChild("StoreProducts"):GetChildren()
for i,v in ipairs(itemCloneTable) do
if v.Part.BrickColor == itemToBeDestroyed.BrickColor then
local itemCloned = v:Clone()
itemCloned.Parent = playerWhoClicked.Backpack
end
end
end)
end
end
---
local itemsTable = shelf:FindFirstChild("Items"):GetChildren()
-- Change colors
for i,v in ipairs(itemsTable) do
v.BrickColor = BrickColor.new(Colors[math.random(1, #Colors)])
end
end