[1.19.2] Botania causes JEI runtime memory leak after reload
embeddedt opened this issue ยท 0 comments
Mod Loader
Forge
Minecraft Version
1.19.2
Botania version
1.19.2-439-FORGE
Modloader version
43.2.13
Modpack info
All The Mods 8 v1.0.19b
The latest.log file
N/A
Issue description
The assignment of CorporeaInputHandler.hoveredStackGetter
in the JEI plugin causes a memory leak if JEI is reloaded a second time, as the previous old
lambda is no longer () -> ItemStack.EMPTY
, and instead holds a reference to the old JEI runtime. This prevents it from being garbage collected and wastes ~600MB of memory in ATM8.
I think a simple way to work around this, if larger code changes are not desired, would be to capture a WeakReference<JeiRuntime>
inside the lambda instead of a direct reference to the runtime.
I have not tested but I assume REI/EMI may also be affected by this if they use the same logic. I am also not sure how old this code is, the leak may also be present in 1.18 and 1.16.
Steps to reproduce
- Launch the game and open a world.
- Run
/reload
. - Use a heap dump tool to observe the old JEI runtime being retained via Botania's lambda, and nothing else.
Other information
No response