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

SSP Leaking memory when connecting and disconnecting from worlds

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Duplicate
    • Affects Version/s: Minecraft 1.6.2
    • Fix Version/s: None
    • Labels:
    • Confirmation Status:
      Unconfirmed

      Description

      Steps to reproduce:

      1) Enter a world
      2) Hit F3 and look at the memory and on which value it drops when the GC runs.
      3) Wait a minute so that more chunks load then disconnect
      4) Go back to 1 and see that the value it drops to is higher then before
      5) Repeat this until you'll possibly have an out of memory error

      The problem here is that some of the resources of the IntegratedServerListenThread aren't released properly. Basicly netMemoryConnection field is never nulled once created and that's ok but MemoryConnection class holds a reference to NetHandler (myNetHandler) that holds references to the current world and so all the data associated with it.
      myNetHandler is only nulled in closeConnections and that function is not called for the integrated server, so after stopping the integrated server that reference still holds, keeping everything in memory.
      But even calling closeConnections there's a second place where references are held.. and this is in NetworkListenThread, connections field.
      There connections are removed in networkTick, but what happens with the Integrated Server is that the server is stopped before it can tick and so the connections List isn't emptied.. and that again holds indirectly references to the world data.

      Personally i've fixed it like this: http://pastebin.com/QHfdke9b

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                smjert Stefano Bonicatti
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: