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
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)
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
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
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?
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.)
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
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.
We’ve now been at it for a week, trying to make our own, custom artificial playercap. It’s proving to be a REALLY big challenge, and has been expensive to make. It’s a shame Roblox wouldn’t just allow us more customisation.
It’d be great if we could set the Max visitor count to 700, then set the reserved slots to 600, so servers never fill up more than 100, using Roblox’ built-in systems.
Hey guys! Good news is that development on a tool which will help us diagnose this (and other similar leaks) is now development-complete. We are testing internally and I will be using this tool soon to make progress on this report. Thank you so much for your patience, it was important for us to take the long solution so we are better equipped in the future.