When i use OnServerEvent. i don’t disconnect it. if i am to disconnect when should i? can i just leave it waiting for events to be fired and it not have memory leaks. because connections cause memory leaks. so yeah. also if your game doesnt have a data store. should you worry about memory leaks??
There wont be a memory leak unless you use it too may times in a time frame, but Roblox would warn you before that happens. The only time you should disconnect it is if you are sure that you’re not going to use it again.
Memory leaks are things that make the client/server have more RAM used than normal, for example, the memory might skyrocket from 200mb to 1000mb, signifying that there is a memory leak.
Any instance can leak memory if they aren’t cleaned up properly. RemoteEvents being strongly referenced and not handled correctly can leak memory, so can OnServerEvent connections that aren’t disconnected. Always destroy objects you don’t require anymore and disconnect connections you won’t need any more.
Chances are you won’t ever need to disconnect anything from OnServerEvent so it’s fine to leave it because realistically you will need it.
More information:
Thanks the replies helped me feel more comfortable with using remoteevents