The following is based on a decompiled version of Minecraft 1.9 using MCP 9.24 beta.
This has very likely only an effect on the title screen.
When you switch to title screen the garbage collection cannot collect everything from the world you had open before because Minecraft.pointedEntity still references it.
To reproduce, simply quit to the title screen while looking at an entity. The field will not be set, and a WorldClient instance will be leaked.
This happens because the field is not set to null on the world changing, and EntityRenderer.getMouseOver only sets it to null when there is a render view entity (and a world to render).
This uses the 1.18.1 symbol map.
- First, locate net.minecraft.client.Minecraft (for 1.18.1, this is dxo), crosshairPickEntity (u), and void runTick(boolean) (f).
- In the Minecraft launcher, add -agentlib:jdwp=transport=dt_shmem,address=mc,server=y,suspend=n to the JVM arguments.
- Run Minecraft, and open a world.
- Put an entity in a location where it won't escape or move away from the cursor.
- In a separate command-prompt window, run jdb -attach mc. This should attach jdb to the Minecraft process.
- While looking at the entity, run the following in JDB: stop in dxo.f(boolean) (at which point the game should immediately freeze), followed by print u, (which should output the entity you were looking at), followed by clear dxo.f(boolean), followed by resume (which should resume the game).
- In the game, pause, and then save and quit.
- In JDB, again run the commands stop in dxo.f(boolean), print u, dxo.f(boolean), and resume.
- The print command will still output the entity, even though the world should have unloaded; this indicates that memory has leaked to the title screen. (The expected output would instead be null).