We have identified a memory leak in Minecraft's Pathfinding System.
In MCP Naming, the NodeProcessor class (PathfinderAbstract in mc-dev naming) is the culprit.
First parameter is IBlockAccess, which is set by the first method in the class. This parameter is set to an instance of a Chunk Cache.
However, the 2nd method called postProcess in MCP, never cleans up this reference.
This causes an Entity's Pathfinding instances to hold onto a reference of a ChunkCache.
This ChunkCache then holds references to many Chunks, even after they unload.
These unloaded chunks then hold references to other leaked Entity objects, who also have references to Pathfinders...
This leaks to potential to create a chain of leaked objects.
Attachments
Comments


My fix patch can be seen here: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/CraftBukkit/commits/f92e01ba5cf

I think I am able to confirm.
[Edit: I am definitely able to confirm]

Interesting. I've yet to try your patch, and to see if it just works for you or if it works for both of us.

Good catch.
The reference was indeed never release. Thanks for pointing it out.

Is this the cause of MC-94438?

Possibly, we'll see if that gets fixed next version as well

I don't believe so, as this memory leak also affects 1.8.
I wonder if MC-94438 has to do with Grass blocks triggering Chunk Loads for Light Level checks.
As that is another flaw we've recently found.
My quick bandaid for that in paper is to return 0 for unloaded chunks light level... Which should only ever happen for blocks that gather light data from neighbor, and that would result in it using 1 of the other 3-4 neighbors.
Maybe thats good enough for Vanilla to do?

See MC-100341 for that.


WHAT IS THIS BUG it's more like a "Security Issue"

@unknown no, it is not. This bug has been in Minecraft for years, and not something players can intentionally trigger at a scale to crash a server.