Hiwi! Thank you for reading
Im trying to learn about CollectionService. It’s going good, but, I have a question about memory leaks, in what type of scenario I need to remove/delete/destroy the connections and the tags?
What would be right and wrong?
A bomb, that already exploded, and its Part its destroyed? Tags and connections should be removed?
A Killing Part placed on the floor that will stay “forever” in the server? When to destroy tags?
I really dont understand the memory leaks, and stuff related… To what, should I put more focus?, thank you for ur help
If a part is destroyed, all connections to it should be cleaned up as well, including tags.
CollectionService tags shouldn’t cause memory leaks.
Delete a tag whenever you’re absolutely sure you’re not going to add any more items into it anymore. Even then, empty tags (tags with no parts connected to them) shouldn’t cause any memory leaks; if they do, it’s most likely negligible to performance.
If the part is destroyed, you don’t need to worry about disconnecting any connections to the part, it’s done automatically. You can disconnect it manually when you destroy it though just to be safe.
You don’t have to do anything here. This isn’t going to cause a memory leak unless you keep stacking connections to the part. If it’s one part that’s never going to change or be destroyed, all you need to do is connect all your connections once.
ohh question, If I clone a ServerStorage part 100 times and place them when the server starts, tag all of them, connect them to a function then I will never create any more parts of that class or add any other function to them, those will stay forever in the server, I should untag them?
Thank you so much for ur explanation, very clear! I readed some topics about this, but its very confusing like ethereal, not real topic, all these behind curtains stuff, like memory leaks. Thank you!
Tag the original part first before cloning it 100 times, so that you already have the tags on the clones. If you don’t want the tag on the original you can remove it after you clone it 100 times.
Also, what do you need the tags for then? It’s hard to answer the question cause I don’t know what the tags are for. If you always need the tags, you don’t need to untag them; they will stay tagged until the server dies. Unless you for some reason don’t need the tag anymore, you can keep the tag in.
Are you using the tags just to connect all the clones under it to a function? If you only need it for those 100 clones you don’t even need CollectionService - you can just connect the function in the for loop (that you clone the part with). If you always need that function to be running no need to disconnect.
Yup!! This makes more sense, tag only one part, then clone it. Actualy very more efficient.
You mean connect the Part to a function when the cloning loop is running, so will not need Tags to look for it later, cause its already done with its connection and stuff. Yup! totally, thats what I did firstly.
On my post usually I dont describe a situation, cause Im not exactly creating “something” Im just testing and learning, to see the “skills” of methods/techniques, for when I’ll try to make a complex system I can easily know what would be a “better” aproach.
In the end, I kinda feel that CollectionService is useful to have “a little more easier access”, to stuff in server, and I really dont find clear reasons to delete the tag, cause I would lose that “easier access”… I find other type of methods easier or at least less “weird warnings” xD
Anyway, thank you so much for ur time… pfff sorry… I always write too much… I get lost at thinking when writting :vv