Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-101260

Minecraft.pointedEntity leaks the previous world when returning to the title screen


    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 1.9.2, Minecraft 1.12.2, Minecraft 18w15a, Minecraft 1.13, Minecraft 18w30a, Minecraft 18w30b, 1.18.1
    • Confirmed
    • (Unassigned)


      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.

      The bug

      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).

      To reproduce

      This uses the 1.18.1 symbol map.

      1. First, locate net.minecraft.client.Minecraft (for 1.18.1, this is dxo), crosshairPickEntity (u), and void runTick(boolean) (f).
      2. In the Minecraft launcher, add -agentlib:jdwp=transport=dt_shmem,address=mc,server=y,suspend=n to the JVM arguments.
      3. Run Minecraft, and open a world.
      4. Put an entity in a location where it won't escape or move away from the cursor.
      5. In a separate command-prompt window, run jdb -attach mc. This should attach jdb to the Minecraft process.
      6. 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).
      7. In the game, pause, and then save and quit.
      8. In JDB, again run the commands stop in dxo.f(boolean), print u, dxo.f(boolean), and resume.
      9. 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).

            Unassigned Unassigned
            marcono1234 [Mod] Marcono1234
            11 Vote for this issue
            9 Start watching this issue