I was doing some research into a project’s poor memory performance by testing stuff on a blank baseplate, and found that Instances, PhysicsParts, and Animation are leaking a significant amount of memory every time a character loads. You can reset several times, then leave the game, and that memory will never be released.
Here you can see me resetting my character several times, then leaving the game entirely. Memory for this category hangs higher than where I started resetting and never drops back down.
This is reproducible on a blank baseplate, both in Studio and in a live game.
This is causing significant problems for my experience, as servers can start reaching RAM usage nearing 6GB+ after 10 hours and hundreds of users.
EDIT 5/1: After applying the destroy character fix (code below) and fixing a number of leaks that were my own fault, servers should theoretically be lasting 55-60hrs+ before crashing out due to an overload of PhysicsParts. It remains to be seen whether the remaining PhysicsParts memory is due to a leak of my own making, or is leftover from the issue reported here.
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
player.CharacterRemoving:Connect(function(character)
character:Destroy()
end)
end)
I did some initial tests with this bandaid on a blank baseplate and the results show it might be helping. I’m waiting on some data to populate after I pushed the patch live last night to see for certain how much it helps in practice.
This fix shaved about 10-15% off of my total memory usage, maybe a little more if you factor out UntrackedMemory, and it was basically free. Good find!
There’s also nothing but a baseplate in this game and I didn’t even reset my character at all, so this kind of unneeded high memory usage is just unacceptable at this point.
I can’t even work on any projects without worrying about my low-end computer blowing a fuse over something simple in Studio, so hopefully this gets resolved quickly.
hi, animation, physicsparts and instances are still leaking server-side memory on a blank baseplate, despite setting PlayerCharacterDestroyBehavior to true. Manually destroying the character on CharacterRemoving doesn’t work either.
My biggest concern is with animation, as a character could be loaded up with a bunch of animations that takes up a lot of memory, and dying a bunch of times on top of that means memory leaked = # animations loaded * # times character reset, you can see how fast that can add up.
In my tests, server side animation is consistently the fastest rising stat in memory usage.