spigot/CraftBukkit-Patches/0088-Plug-WorldMap-Memory-Leak.patch
2019-04-30 21:46:22 +10:00

44 lines
1.7 KiB
Diff

From 0191a883fc0eb0f04dc568b03000e11b0687bba0 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Fri, 8 Aug 2014 19:57:03 +1000
Subject: [PATCH] Plug WorldMap Memory Leak
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 1a49f164c..4c9a54239 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1022,6 +1022,30 @@ public class WorldServer extends World {
}
public void unregisterEntity(Entity entity) {
+ // Spigot start
+ if ( entity instanceof EntityHuman )
+ {
+ this.getMinecraftServer().worldServer.values().stream().map( WorldServer::getWorldPersistentData ).forEach( (worldData) ->
+ {
+ for (Object o : worldData.data.values() )
+ {
+ if ( o instanceof WorldMap )
+ {
+ WorldMap map = (WorldMap) o;
+ map.humans.remove( (EntityHuman) entity );
+ for ( Iterator<WorldMap.WorldMapHumanTracker> iter = (Iterator<WorldMap.WorldMapHumanTracker>) map.i.iterator(); iter.hasNext(); )
+ {
+ if ( iter.next().trackee == entity )
+ {
+ iter.remove();
+ }
+ }
+ }
+ }
+ } );
+ }
+ // Spigot end
+
if (entity instanceof EntityEnderDragon) {
EntityComplexPart[] aentitycomplexpart = ((EntityEnderDragon) entity).dT();
int i = aentitycomplexpart.length;
--
2.20.1