CommandBase.commandListener retains old server reference, preventing garbage collection
During server startup, ServerCommandManager() calls CommandBase.setCommandListener() with itself as the argument.
This means that the CommandBase class holds a staic reference to the command manager, which holds a reference to the server.
As the server holds references to many game objects, this link keeps a fairly large amount of memory from being garbage collected if the application continues, which is the case for the single-player client.
This can be seen by starting the single-player client, loading a world, and then quitting to the title screen, then taking a heap dump of the application.
While this is not a permanent leak, as the field will eventually be overwritten, it causes memory to stay in use a lot longer than it would otherwise, and increases memory demands to load subsequent worlds.
A solution here would be to add a call to CommandBase.setCommandListener(null) in MinecraftServer.stopServer(), either directly or through ServerCommandManager.
2018-04-16, 04:43 AM
2018-04-16, 07:08 AM
2018-04-16, 06:39 AM
1
1