Closed ViRb3 closed 5 months ago
What is the need for both that additional event handler and making all the maps weak? Are there cases which one or the other doesn't cover?
No, either one is fine, added both for additional safety and error proofing as mentioned in the PR. Feel free to keep only one of the two if you prefer.
I've been profiling All the Mods 9, a heavy modpack with 400+ mods, to try and reduce the most impactful memory leaks. I discovered the maps in InputHandler transiently hold onto a reference of ClientLevel, which weighs over 300MB. Since the maps are not unloaded on client side disconnect, every rejoin of the server adds another 300MB of consumed RAM, quickly making the game very laggy.
The problem can technically be solved by only adding weak maps, or only by capturing client side disconnect and clearing, but I figured adding both is more error proof for the future. Feel free to adjust if necessary. Thanks!