godot
godot copied to clipboard
ENet server memory leak when clients disconnect abruptly
Tested versions
Reproducible in Godot 4.4 dev3, Godot 4.3 stable
System information
Godot v4.4.dev3 - Windows 10.0.19045 - Multi-window, 2 monitors - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 3060 (NVIDIA; 32.0.15.6109) - 13th Gen Intel(R) Core(TM) i9-13900K (32 threads)
Issue description
I am building a server app for my multiplayer game using ENet Connection with DTLS, and I think I found a memory leak: when clients are closed suddenly with kill process, they disconnect on the server side but without freeing the used memory.
In addition, after the Server app reaches ~500MB of leaked memory, I observed a noticeble CPU usage, even when there are apparently no clients connected.
The attached MRP was tested on 3 PCs: locally, over LAN, and over Internet, in both debug and release builds.
Steps to reproduce
Testing with the attached MRP:
- Start the Client and Server apps.
- Press the button in the Client to add 300 clients. This will add ~75MB to the Server app memory.
- Close the Client window normally (from X button or Alt+F4). The Server app memory will decrease and the clients will disconnect.
- Repeat 1 & 2, but this time close the Client app by killing its process from Task Manager (or using the Stop button in the editor). The clients on the Server app will disconnect as usual, but the memory will not decrease.