lemur
lemur copied to clipboard
Lemur's :Destroy() disconnects all listeners despite that not being a feature of :Destroy()
https://github.com/LPGhatguy/lemur/blob/42e609ea4761f648eb1e556274c0030c2a0f50a4/lib/instances/BaseInstance.lua#L204
I assume this line is to replicate the behavior that disconnects all events when :Destroy() is called, but this (at least from reading the code, I haven't tested it) also breaks GetPropertyChangedSignal
connections.
local part = Instance.new("Part")
part:GetPropertyChangedSignal("Name"):connect(function()
print(part.Name)
end)
part.Changed:connect(print)
part.Name = "A"
part:Destroy()
part.Name = "B"
This code will print A and B. In lemur (again, presumably from reading the code) it'd only print A.
Huh. I wonder if this is actually a Roblox bug, since keeping connections around means those objects are probably never cleaned up?
Not sure, I'll test it. I'll make a post on the developer forums if it turns out that this is a real memory leak.
Strange, while the connections aren't cleared the instances ARE cleared from memory.
local memory = {}
for index=1,3e5 do
local instance = Instance.new("Model", workspace)
memory[index] = instance
--COMMENT THIS PART OUT TO SEE THAT WITHOUT IT, THE MEMORY IS CLEARED
instance:GetPropertyChangedSignal("Name"):connect(print)
if index % 3e4 == 0 then
wait()
end
end
print("DONE MAKING STUFF IN MEMORY, CHECK DEVELOPER CONSOLE (PhysicsParts)")
workspace.Part.ClickDetector.MouseClick:wait()
print("Clicked")
for index,value in pairs(memory) do
value:Destroy()
if index % 3e4 == 0 then
wait()
end
end
print("All destroyed, check memory")
--while true do wait() end