I am dealing with some more memory leaks in my game and I am trying to get a better understanding of it by testing some stuff out in an empty place.
What I’ve got is a localscript that clones in 500 localscripts which setup some stuff to take some memory. This causes Client Memory Usage to jump by about 1000.
I then wait some time and then disconnect all the connections and set all variables nil. But I ntoice the Client Memory Usage doesn’t drop much, it drops maybe 200-300, the other 700 seems to just remain forever. I can see in Client Memory that the LuaHeap is sitting around ~1000.
I feel I must be misunderstanding something about all of this.
localscript for creating a bunch of localscripts to take up some memory
task.wait(5)
local ls = script.LocalScript
for i = 1, 500 do
local l2 = ls:Clone()
l2.Parent = game.Players.Askavix.PlayerGui
l2.Enabled = true
end
print'1'
task.wait(20)
print'2'
localscript that is being cloned, yes I know the clean up is messy and overkill but the issue is that in spite of this it doesn’t seem to be clearing up the memory it used.
local stuff = 123123
local a = 1
local b = "ssgsgsrgrsg"
local a1 = workspace:WaitForChild("Baseplate").ChildAdded:Connect(function()
local d = 3
local g = "srgsrgrsgr"
end)
local a2 = workspace:WaitForChild("Baseplate").ChildRemoved:Connect(function()
local d = 3
local g = "srgsrgrsgr"
end)
local ta = {}
for i = 1, 100000 do
table.insert(ta, "rgrsgrsgrsg")
end
task.wait(6)
a1:Disconnect()
a1=nil
a2:Disconnect()
a2=nil
stuff=nil
a=nil
b=nil
for i,v in ta do
ta[i] = nil
end
print'done'
ta = nil
task.wait(4)
script:Destroy()
Shouldn’t all the memory it used basically get cleaned up?