In my game, the player’s data is loaded into Folders (which hold attributes) and when said attributes change, the data also changes (this system is created with ProfileService and ReplicaService, if there’s any improvements I can make, please let me know).
Example : “Currencies” Folder would hold the attributes “Money” and “Gold”.
The problem is that at some points, on the client, I use GetPropertyChangedSignal() on the Folders in order to update the UI, and I don’t know if I should GC these connections when the client leaves.
I’ve already made it so it disconnects these connections when the client leaves, but I was wondering if it’s even necessary since it’s the client.
Alright SOOO, there are a good few libraries that can help you manage this.
The connections you are worried about, are the ones made to other clients and or in the server based on these disconnections and connections.
If you did not hook any up in such a way on another client where it is stored anywhere, then roblox tells us that it handles removing all the connections. That being SAID ! If you stored it anywhere, or if the instance has any tables that reference it, that still exist then the connections will persist.
It will create a quasi state where the instance will be in nil, but can not be garbage collected because another table is referencing it, and thus the connections will persist as a result. OR if you ever referenced the connections directly, and you did not clear those references out, it may get stuck in the similar quasi state.
If you want to be super safe, I highly suggest, maid or janitor. Look them up on github they are pretty solid for this. I don’t use them atm, sadly on my project I already wrote something that I use too much, but in the future I would likely use one of those to help manage those conditions best.
IMO with roblox it is always better safe then sorry. Any connections that you will be breaking or things making sure they are cleaned manually is a good thing to do.
I am weird and generally speaking I don’t make connections that are not perminate connections. And anything that is def going to get broken I store and ensure I manually destroy and clean up references to those connections just out of safety. But that could be overkill on my part.