Hey you all. I’m currently making a data saving system and I need it to be updated whenever the player’s leaderboard value changes.
It works, but I’m not sure if I should worry about the server eventually shutting down from taken up memory, since when a player is added, 2 different GetPropertyChangedSignal() methods are used.
I couldn’t find anything specific about this anywhere.
So the main question is: If the player leaves, does the property signal stop, or do I have to stop it in order to save memory?
(Uses Profile Service)
Here is the code if you need it:
cash:GetPropertyChangedSignal("Value"):Connect(function()
--Update Data
end)
wins:GetPropertyChangedSignal("Value"):Connect(function()
--Update Data
end)
This is significant, as the first connected function contains a reference to the signal’s associated instance in its closure. If the player is not destroyed (which would disconnect all signal connections from its descendants), this cycle of references will keep the value object (and by consequence its connections) from being picked up by garbage collection.
The second approach solves this problem, as it avoids the need to reference the signal’s associated instance, by instead being fed the changed value directly.