Reproduction Steps
Typically after disconnecting a connection you can expect it to be fully garbage collected after a short period of time. This does not occur for connections formed with GetPropertyChangedSignal. appear to occur within the console.
This can be reproduced with the following code:
local changedSignal = workspace.Baseplate:GetPropertyChangedSignal("Parent")
for i = 1, 10 do
local connection = changedSignal:Connect(function()
end)
print("Formed connection", i)
task.delay(1, function()
print("DISCONNECT", i)
connection:Disconnect()
end)
wait(1)
end
This video demonstrates the memory leak:
Even at 1:10 when the original instance ‘Baseplate’ is destroyed, the memory does not return to normal.
Expected Behavior
Memory to return to its original value within about a minute.
Actual Behavior
Memory does not return to normal indicating a leak.
Issue Area: Engine Issue Type: Performance Impact: High Frequency: Constantly Date First Experienced: 2021-09-07 00:09:00 (+01:00)
Did you see this causing any issues in any production game? I’m wondering if this actually may be due to how we are tracking Server memory in the Developer console.
I tried the following code and was still able to reproduce the issue:
local changedSignal = workspace.Baseplate.Changed
for i = 1, 10 do
local connection = changedSignal:Connect(function()
end)
print("Formed connection", i)
task.delay(1, function()
print("DISCONNECT", i)
connection:Disconnect()
end)
wait(1)
end
Then I tried the original code in a LocalScript and was not able to reproduce the issue:
So I don’t think this is really a memory leak caused by GetPropertyChangedSignal, but it does look like there is a bug here that’s worth investigating.
Thanks for the response, I haven’t noticed any performance impacts related to this in my games, it was just something I stumbled across whilst hunting for an unrelated memory leak.
You’re right that it appears to be the case for any connection instead of specifically GetPropertyChangedSignal so I’ll try and amend the title.