Ars Nouveau

Ars Nouveau

70M Downloads

Memory Leak of MinecraftServer

pietro-lopes opened this issue ยท 0 comments

commented

LOOT_PARAMS is holding the fake player which holds server.
WeakReference don't make any diff on this case due to being stuck on LOOT_PARAMS.

public static void initLootParams(ServerLevel level) {
ANFakePlayer player = ANFakePlayer.getPlayer(level);
LOOT_PARAMS = new LootParams.Builder(level)
.withParameter(LootContextParams.ORIGIN, BlockPos.ZERO.getCenter())
.withLuck(1.0f)
.withParameter(LootContextParams.THIS_ENTITY, player)
.create(LootContextParamSets.CHEST);
}

You might want to add some sort of clean up strategy to set LOOT_PARAMS to null, maybe at Server Stopped event, or if you want to be very accurate, at Level Unload (server side) and compare the LOOT_PARAMS level with the one being unloaded, and nullify it.