Server network/raknet Memory Leak?

It was 12 hours old, but had only gotten above 10/100 players in the last 2 hours of its life, where it was at 80/100 for the entire 2 hours.

1 Like

Hello!

I’m wondering whether or not this is happening to EVERY game on the platform, or just a few ones.

Perhaps it only effects games with plenty of server activity & high server sizes to a point where it is noticeable.


When our servers have 10/100 players on them, they last up to 2 days, but only a few hours at 80+/100. As playercount in each server gets higher, the memory leak becomes exponentially worse. That may be why only a few developers are noticing the issue.

I’m also starting to doubt whether or not it is a Roblox issue at all, considering you have published so many patches to attempt to fix it. Even with all our own memory loggers & other tools showing no leaks, could the memory leak not still be of our own creation?

Thank you,

  • Jaco
2 Likes

correct me if im wrong but what if you just set the values to nil after using them so it doesnt hold the references to them forever?

function FireClients(clients, event, ...)
   for _, client in pairs(clients) do
      event:FireClient(client, ...)
      task.wait() -- artificial delay
      client=nil
   end
   event,clients=nil,nil
end

please let me know if this works or not

1 Like

It didn’t affect anything-----

  • Setting a local variable or a function parameter to nil doesn’t free the memory or dereference the object it’s pointing to. Lua’s garbage collector will automatically deallocate memory for objects that aren’t reachable anymore.

  • client=nil within the loop is unnecessary. It doesn’t impact the actual clients table; it just breaks the reference between the local loop variable client and the current table item.

  • Similarly, event,clients=nil,nil at the end of the function is redundant. Once the function execution completes, local variables (including function parameters) go out of scope, and if there are no references to the objects they pointed to, they are eligible for garbage collection.

Hope this clears that up!

Hey guys - just wanted to pop in to say we’re still working on something internally which will help us narrow down the problem. Thank you for your patience!

As for the question regarding the types of experiences this affects, it seems likely this problem is exacerbated for experiences with many concurrent players for two reasons: these servers tend to live longer with constant player activity, and these servers serve exponentially more traffic.

10 Likes

I want to mention this might be Player instance related issue!

I noticed that when a player leaves the game connections like .CharacterAdded are still connected

to fix this you have to do something like this:

local Players=game:GetService("Players")
Players.PlayerRemoving:Connect(function(p)
	if p.Parent==Players then
		p.AncestryChanged:Wait()
	end
	p:Destroy()
end)

after calling “Destroy” on Player my .CharacterAdded connections get disconnected

When Luau destroys an event’s object all of its connections disconnect automatically ~

How did you come to the conclusion that the event was not disconnected? If you stored the connection in a local variable, that variable may not be nil but the connection should be disconnected

1 Like

When Luau destroys an event’s object all of its connections disconnect automatically

correct but what im trying to say is that when player leaves the game all of connections related to that player (like .CharacterAdded) are still connected

this can be fixed by connecting to PlayerRemoving and then calling :Destroy on that Player instance just to disconnect .CharacterAdded

local Players=game:GetService("Players")
Players.PlayerAdded:Connect(function(p)
	local connection=p.CharacterAdded:Connect(function()
		
	end)
	Players.PlayerRemoving:Wait()
	p.AncestryChanged:Wait()
	print(connection.Connected,p.Parent)
end)
game:BindToClose(function()
	task.wait(2)
end)

Zrzut ekranu (124)

so in order to fix this

you have to add this few lines of code:

Players.PlayerRemoving:Connect(function(p)
	if p.Parent==Players then
		p.AncestryChanged:Wait()
	end
	p:Destroy()
end)

I thought this was expected behavior? I have noticed for a while that this has been a feature/bug for a while now with all sorts of instances if I’m not wrong. Like the fact that Humanoid connections stay alive even after the character is destroyed.

yeah thats what probably causes the memory leak (connections are not supposed to stay alive when Instance got reparented to nil! example: player left the game and instead of destroying player roblox engine just parents player to nil and connections related to that player stay alive)

I think that its not expected behavior correct me if im wrong

1 Like

also one thing

roblox engine does same thing to player.Character (just like when player leaves the game)

instead of destroying it its just gonna reparent it to nil and that means humanoid connections will still stay alive (grrr roblox should fix this and start calling :Destroy on those instead of just reparenting to nil)

EDIT: yeah looks like im probably correct with this one

im not the only one who figured out about this stupid memory leak

1 Like

I see, thank you for mentioning that. I can confirm those issues are being looked at. Not sure if they’re related to this network/raknet leak though

2 Likes

Hello again!

Since this problem being fixed assumingly will take many months or quarters to accomplish, is there any way for us to receive larger Memory caps for our servers? 6.25GB memory-cap doesn’t seem like a whole lot.

I’ve had my fair share of Minecraft & ARK servers in the past, and they always needed 8GB+ memory for only around ~10 players to ensure stable gameplay while lightly-modded. An equivalent ARK:Survival Evolved server would require 32GB of memory to sustain 80 players.

  • How come Roblox’ servers have such low memory capacity, without the ability to upgrade them?
  • How does Roblox power imagination when our imagination can no longer be contained by Roblox’ servers? :laughing:

Even an extension of the cap to 8GB, would allow our servers to live for an additional 2-3 hours without crashing. (They crash after 2-3 hrs of 80/100 players currently.)

Thank you for your time,

  • Jaco2811
2 Likes

This would be so helpful! Even after a lot of optimisation, I’m currently unable to release my game to the public because it’s already too close to that 6.25GB mark

1 Like

You can increase your server player count to 600+ players and it’ll be raised to a 12GB limit. You can then wrap your game in a server browser which artificially caps it at your desired count.

The reason that servers are memory capped is, well, they’re free! I wouldn’t want Roblox to charge even for optional “premium” servers because this would go against the philosophy of the shared cost model that Roblox has with developers.

1 Like

You sure this works? If so, that’s awesome! Will try it out.

It works! Holy smokes. Thank you for telling me about this.
image
How did you come to know this info yourself?

Oh, just trial and error! :slight_smile: same way I found out about the 6.5GB regular cap.

What also sucks is half my total memory in my game on Client and Server comes from CoreScripts in which I can’t control.