ManaNetworkHandler may leak client memory
Closed this issue ยท 1 comments
Mod Loader
Forge
Minecraft Version
1.20.1
Botania version
1.20.1-448-FORGE
Modloader version
47.4.2
Modpack info
https://www.curseforge.com/minecraft/modpacks/ctnh
The latest.log file
N/A
Issue description
ManaNetworkHandler may leak memory due to the value reference the level key.
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/WeakHashMap.html
Implementation note: The value objects in a WeakHashMap are held by ordinary strong references. Thus care should be taken to ensure that value objects do not strongly refer to their own keys, either directly or indirectly, since that will prevent the keys from being discarded.
The following images show the GC root. Used VisualVm to dump memory.
Steps to reproduce
- Join a online server with botania mod
- Switch to a different world within the server. Ensure the target world contains Botania mod flowers (e.g., functional or generating flowers).
- Switch to a different world.
- Repeat step
23above. - Observe memory behavior
- After switching, monitor memory usage via the F3 debug screen or external profiling tools.
- Memory usage increases in proportion to the new world's actual memory footprint.
- Even after triggering garbage collection, the memory is not released.
Other information
Quit the server and rejoin will fix the memory leak. But in the modpack case, rejoin server will leak memory by other mods.