Skip to content

Fixed server memory leaks#2097

Open
APERUTRE wants to merge 4 commits intoEpix-Incorporated:masterfrom
APERUTRE:master
Open

Fixed server memory leaks#2097
APERUTRE wants to merge 4 commits intoEpix-Incorporated:masterfrom
APERUTRE:master

Conversation

@APERUTRE
Copy link
Copy Markdown

@APERUTRE APERUTRE commented Apr 3, 2026

Changes

  • Fix player connection cleanup in Process.luau
  • Cancel player load timeout tasks on leave
  • Clear Remote.Clients[key] on player removal
  • Fixed client folder staying referenced in server memory

Why

These changes prevent memory leaks on server which could impact the server on long uptime

Note

i made a pull before this one but i fucked something up and didn't see it

Testing

Tested in Roblox Studio with multiple players joining and leaving. Confirmed that:

  • player specific connections are disconnected on leave
  • delayed load timeout tasks are canceled on leave
  • Remote.Clients[key] is removed on leave
  • client folder doesn't stay referenced after player leaves

Proof

before
image
after
Screenshot 2026-04-03 181144

APERUTRE added 2 commits April 3, 2026 17:36
## Changes
- Fix player connection cleanup in `Process.luau`
- Cancel player load timeout tasks on leave
- Clear `Remote.Clients[key]` on player removal
- Fixed client folder staying referenced in server memory

## Why
These changes prevent memory leaks which could impact the server on long uptime

## Testing
Tested in Roblox Studio with multiple players joining and leaving.
Confirmed that:
- player specific connections are disconnected on leave
- delayed load timeout tasks are canceled on leave
- `Remote.Clients[key]` is removed on leave
- client folder doesn't stay referenced after player leaves
Comment thread MainModule/Server/Core/Process.luau Outdated
Comment on lines +905 to +907
if Remote.Clients[key] then
Remote.Clients[key] = nil
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Remote.Clients[key] should only be dereferenced after a 1 second delay and it's confirmed that no player with the aformentioned UserId is in the server again (in case of quick re-join).

task.delay(1, function()
	if not service.Players:GetPlayerByUserId(p.UserId) then
		Core.PlayerData[key] = nil
		-- move the Remote.Clients[key]=nil here instead?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea i think that would be better

Comment thread MainModule/Server/Core/Process.luau
Co-authored-by: Wilson Simanjuntak <wilsontulus5@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants