Background
The Roblox avatar sound system creates a script in ServerScriptService named SoundDispatcher
to replicate sound events between players. Devs can override it by placing their own SoundDispatcher
script in ServerScriptService.
The bug
Today we discovered a memory leak in SoundDispatcher.
Briefly, it holds references to Player instances forever without releasing them on player leave, causing Players to never be freed from memory.
The fix
If you have not overridden SoundDispatcher (i.e. most of you), sit tight and we’ll release a fix in the coming weeks. You don’t have to do anything.
If you have overridden SoundDispatcher, you have two options:
- Unfork it: Remove your custom SoundDispatcher script from ServerScriptService. This way ensures that you’ll continue to get critical updates to SoundDispatcher moving forward.
- Fix your forked copy by applying this patch:
@@ -57,4 +57,5 @@
DefaultServerSoundEvent.OnServerEvent:Connect(function() end)
AddCharacterLoadedEvent.OnServerEvent:Connect(addCharacterLoaded)
RemoveCharacterEvent.OnServerEvent:Connect(removeCharacter)
+ game:GetService("Players").PlayerRemoving:Connect(removeCharacter)
end