Server network/raknet Memory Leak?

This is a problem inside my game, which actively uses remote events and remote functions, since this is a communication game, the server has a maximum of 110 players, but the server has too much memory in CoreMemory/network/raknet.

1 GB of memory, is this normal? If this is expected, are there better ways to use remote events and remote functions?
This affects the performance and stability of servers.

12:42 timestamp:

image1

16:20 timestamp:

image2

Expected behavior

This memory area should use an adequate amount of memory, at least not more than 300 MB or so, and stay at this point for the entire active operation of the server.

28 Likes

Hi @pozzzy333 !

What kind of data are you sending through remote events and functions?
Do you notice CoreMemory/network/raknet consistently growing, or does it plateau around 1 GB of memory?
How long have you been experiencing this issue?

Thank you for your report!

7 Likes

Hi @PlumJar ,
The client sends some data, some numeric and string values, and a couple of small tables to the server. But the server very often sends large tables to the clients in order to keep the client’s data in sync with the server, these tables are very large as they are used by the client when it receives them.

According to my observations, this area of ​​memory grows slowly, at first it may seem that it stands still, but in 2 hours it can swell by 30-80 MB, indefinitely, until the server crashes due to memory overflow.

A full server with 110 players will be enough for about 17-30 hours of continuous work, after which it will be crashed. If you need, I can send a link to my game in a direct message so you can watch it yourself.

6 Likes

Thanks for the extra info, we have a lead on what might be causing this issue and have a patch coming next Tues/Wed. which we believe should fix this.

I will follow up with you to confirm afterwards if you are no longer seeing the issue.

6 Likes

The patch is slowly starting to rollout, and should be fully rolled out tomorrow.

Existing servers should stop seeing endless memory usage growth (beyond what is normal), however they will not “shrink”.

New servers should no longer experience this issue.
I will check back in tomorrow or later this week to confirm the fix! Thanks for your patience!

6 Likes

@pozzzy333 Please let me know if the issue is resolved on your end!

Thanks again for the report.

3 Likes

Okay, I need to monitor the state of memory for a while so that I can give an accurate result. I’ll try to answer on Saturday or Sunday.

5 Likes

I think that the problem has not been solved, because the memory is still increasing, I recorded the state for some time, and I got this list:

06/01/2023 7:15 AM - Server Runtime: 4.09 hrs, raknet memory: 623 MB, Players: 104
06/01/2023 3:19 PM - Server Runtime: 11.9 hrs, raknet memory: 905 MB, Players: 110
06/01/2023 10:52 PM - Server Runtime: 18.8 hrs, raknet memory: 1133 MB, Players: 105
06/02/2023 1:15 AM - Server Runtime: 20.8 hrs, raknet memory: 1206 MB, Players: 110
06/02/2023 6:46 AM - Server Runtime: 25.5 hrs, raknet memory: 1420 MB, Players: 41

Newer servers experience the same problem

2 Likes

Thanks for providing that. Sorry the patch did not fix the issue for you; we will keep investigating and I will let you know when I have another update!

3 Likes

@pozzzy333 Still investigating. Any idea when you first noticed this issue? And does this issue show up in any other memory categories, or just CoreMemory/network/raknet?

Thank you for your patience!

2 Likes

I noticed this recently, but it seems to me that it has been problem around for a long time, because I noticed performance problems for a long time, but could not know their cause for a long time. I also have problems with UntrackedMemory, I can’t know exactly how it is related to raknet, but UntrackedMemory can reach 4-5 GB and the server will crash after 50-60 hours of runtime

3 Likes

Hi PlumJar,

Thank you for the insight here - my game (link here) has been experiencing a very similar increase (under network/megaReplicationData, network/raknet, and network/replicationCoalescing as well as UntrackedMemory) for the last two years. Servers were crashing at 6.5GB of memory after an hour of playtime. Our solution after a few months of trying to debug it was to increase the server player cap to >600 which gave us 12GB of memory for breathing room.

Here’s the bug report filed at the time: Roblox internal memory leak causes my game servers to undiagnosably crash every 3 hours - Bug Reports / Engine Bugs - Developer Forum | Roblox; considering the pattern here this appears to be related to that issue.

I have noticed, however, that this memory leak doesn’t seem to be passive - instead it looks to be actively caused by some event on the game. I’ve tried narrowing it down to a particular action but haven’t had any luck. @pozzzy333 have you noticed the same? (the rate of increase isn’t constant).

3 Likes

Hi @unix_system Thank you for sharing your report. Sorry it seems the previous time you reported this issue the report went stale without resolution. The more information I can get, the better - I will keep you guys updated

7 Likes

Yes, the growth rate is not constant, and the server may crash at different times, I noticed this thing when I started getting different memory stats after the same amount of time. Most likely it depends on the actions of the players, perhaps some players perform a certain action more times than at other times, most likely these are remote events and remote functions. My game uses a large number of remote events and each player sends and receives them at different times and frequencies. Perhaps there is often synchronization of requests, when the maximum number of players simultaneously send requests, creating mini DDoS, dynamic systems can synchronize with time for a certain period of time. This is a thing of servers with a large number of players. (This is just my guess and may not be accurate.)

3 Likes

Just wanted to post a quick update before the long weekend — I have been unable to repro using some test places I prepared which exercise things like remote events/functions etc, but of course these test places are less sophisticated than your guys’ live games. This, along with the suggestions that the growth rate is not constant lead me to agree that the leak may be related to some specific behavior. Next week I will be monitoring memory stack traces to hopefully see exactly where this memory is going.

Thanks for your patience!

3 Likes

We’re also noticing a similar issue with raknet and untracked memory growing to high levels (although not as pronounced) in our game with 65 player servers;


2 Likes

I’ve also noticed this in my game that has 100 player servers for at least a couple months now. network/raknet is consistently over 1GB on older servers.

Here is a screenshot from a server that is 22 hours old:


2 Likes

I just looked at my old notes where I monitored this issue in November 2021, most likely I met this issue earlier, but I don’t have much information about it, it’s very old

1 Like

Just our of curiosity, does your game use any networking/replication libraries?

1 Like

No, I use basic roblox functions FireServer, InvokeServer, FireClient, FireAllClients.

3 Likes