On player load PhysicsParts memory increases permanently, resulting in crashes and severe lag

Reproduction Steps

How to reproduce:

Create a fresh baseplate.
Look at PhysicsParts and Instances Server memory usage.
Reset a couple times.
Look at memory usage again.

Issue has been occurring for about a year or so now. We did not isolate the problem until today after extensive testing. Our game is called SCP: Site Roleplay. It is a combat heavy game with lots of death. This bug causes servers to grow extremely unstable as they age and more players load/respawn. This eventually leads to the entire server crashing, but before that it affects all aspects of our game, mainly the movement of our SCP’s and doors not opening/closing correctly, etc. It is extremely detrimental to our player experience.

The AI will slow down and their walkspeed gradually decreases. The memory never stops growing. I sat and looked at it for almost an hour and did extremely intensive testing. I tried in 5 different places and the issue occurs in all of them. I had 4 of my staff members spam reset and respawn and the memory only spikes when they respawn, not when they die. It will attempt to stabilize and lower a little bit but it stays elevated permanently despite that and continues to do so until the server can’t handle it anymore and it just dies.

Expected Behavior

Memory should stay stable and not increase permanently or clean itself after a little bit of waiting.

Actual Behavior

Memory continues to rise permanently on character respawn/refresh/join.

First image is a fresh baseplate where I’ve done nothing except load in.

Second image is after resetting 5 times. The image clearly shows 5 different spikes and the memory did not budge from 1.910 until I reset one more time and it raised to 1.941.

Third picture is from our actual game. Had one of my mods run :refresh command like 10 times. You can see the huge spikes as he refreshes himself repeatedly. Then when he stopped the memory stayed stable and did not budge.

Fourth image is occurs right after the third one, I had all 4 of them spam refresh many times and it spiked by about 4 MB total as you can see.

Image 5 is when it tries to clean itself? I am not 100% sure how memory stuff works on Roblox so I apologize if my terminology is wrong here. But it clearly tries to do something then it stabilizes around 311.930-311.940 and does not budge until more people respawn.

Image 6 is an older public server (about 5 hours old) which you can see has very high memory usage.

KEY EDIT: Found a workaround after testing. It might not remove the issue 100% but the difference is night and day compared to before. With this script added the game actually attempts proper garbage collection and clears memory consistently. Add to ServerScriptService.

Script made by BananDev

> local players = game:GetService("Players")
> 
> players.PlayerAdded:Connect(function(player)
> 	player.CharacterRemoving:Connect(function(character)
> 		character:Destroy()
> 	end)
> end)

Issue Area: Engine
Issue Type: Performance
Impact: Very High
Frequency: Constantly
Date First Experienced: 2021-12-01 00:12:00 (-06:00)
Date Last Experienced: 2023-01-01 00:01:00 (-06:00)
A private message is associated with this bug report

27 Likes

I also reported this directly via PM.


They should get on this soon.

9 Likes

Can you send a profiler dump so we can check the memory? Press Ctrl+F6, wait until memory gets bad enough, and press dump. It should save an html file to your user folder that you can post or DM me.

8 Likes

Here is my game’s profile when it was lagging until I applied the fix above, it still lags, but less.
log_DB266_microprofile_20221228-023530.html (3.4 MB)

4 Likes

Seems they patched it up.


@Melsteads @TimTsuki

4 Likes

Nevermind. When you disable this fix given above;

local players = game:GetService(“Players”)

players.PlayerAdded:Connect(function(player)
player.CharacterRemoving:Connect(function(character)
character:Destroy()
end)
end)

The game starts lagging again.

This may come from the fact I disable collisions between players.

3 Likes

on my game i disabled starting forcefield, may this had to do something with that??
Look my problem with this issue on this post: The Game Freezes after a Roblox Update

3 Likes

sorry i just saw this, what fix exactly? the “roblox” one or the one given by XanhChronoktus? i will test that script on my game and see

2 Likes

checked both and the solution given on this post and the problem prevails. is not fixed and roblox staff haves to keep looking

3 Likes

Roblox apparently made a fix on it, and there was also a script fix on it. When I used the script fix it was better. But when the fix is not applied, it still lags.

3 Likes

for me is the same it keeps occurring

2 Likes

Still occurring if this is disabled.

1 Like

Can confirm this exact same behavior for Gem Galaxies, a roleplaying game that uses an older method of welding parts to a rig to create a morph. However, upon switching between the server welding the rig and having the rigs pre-welded with characters, the PhysicsParts still increases when you switch characters (via doing Player.Character = NewCharacter) and them resetting/leaving.

As such, when the server reaches about 5000MB-ish (within 6 hours, since a lot of people come and go, switch characters and such) in total usage, the server’s chat begins to give out before it inevitably crashes. I’m going to implement the fix as said up above + some.

3 Likes

Sad to see that they didn’t fix this yet…

3 Likes

Nothing has been fixed yet, any news?

1 Like

Nope, I am still experiencing this issue.

2 Likes

Same here. In the patch it said it was fixed, but i guess not.

1 Like

After 1 month still no news, it’s getting annoying

2 Likes

There has been no news on or fix for this issue and it has been multiple months. I am quite embarrassed that Roblox is incapable of fixing such a major engine issue.

4 Likes

the issue was fixed for me after a roblox update the 12/01/2023
it started happening the 11/12/2022 for me BUT yesterday 28/03/2023 this issue started happening again, some roblox forum moderator unlisted my post about this who knows why, makin so i have to put all over again.
They keep getting randomized messages as a proof of never ending loading onto the game or random crashes because of the last roblox update yesterday.
image


image


image
image

to be clear, i didn’t update the game that time, so this started happening randomly even with old versions of the game after a ROBLOX update.

22 Likes