The remote events firing are not an issue. Here is an example of code that would leak memory similar to your situation.
RemotEvent.OnServerEvent:connect(function(Player)
Player.Character.Humanoid.Changed:connect(function()
print('Hello!')
end)
end)
If you were to call this event repeatedly from a client, every time it is called a new Changed connection for the humanoid is created on the server. However, all of the previous Connections created when the Remote Event was fired will still exist in memory (and connect on every change)
This means that if you were to fire the event from a client 100 times, the server will fire the Changed connection 100 times for every 1 time there is actually a change (because you created 100 connections). This means you have consumed 100x the memory you need, and will consume more every time another Changed connection is created inside of the server event connection.
A single connection to each remote event will not leak memory, because it is never re-created (and therefore always takes the same memory, even if it’s repeatedly called). It would only be an issue if every time the Connection occurs, you consume memory that is never freed. If the connection does not consume more memory every time it is fired, it will not be an issue.
Edit: It should also be noted that creating connections are not the only thing that will consume memory. Anything you create that exists outside of the function you want to run (i.e a non-local variable, adding items to a non-local table) will continue to exist in memory once the function ends.
function ConsumeMemory()
Hello = "I consumed memory!"
end
ConsumeMemory()
print(Hello)
will print “I consumed memory!” because the variable was not local, and will exist after the function has ended.
function WontConsumeMemory()
local Hello = "I consumed memory!"
end
WontConsumeMemory()
print(Hello)
will print nil
because the variable was local, and is no longer in memory.
The first time you run ConsumeMemory() it must define the variable “Hello” to be remembered by the script later. Since it was not done locally, when the function ends, that memory still exists.
In the second example, the memory to store “Hello” will only be taken until the function ends, and the local memory no longer exists.
There are times you will want to create memory that is not removed once a function has ended. However, these are the things that have the potential to create leaks. You must be careful that once the memory is no longer needed, you remove it properly.