spigot/CraftBukkit-Patches/0088-Plug-WorldMap-Memory-Leak.patch

44 lines
1.7 KiB
Diff

From e5a869368b953a2bfc18621f27b4263d2c9df3c3 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 24d8b2a6a..9411a4c80 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1023,6 +1023,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).dU();
int i = aentitycomplexpart.length;
--
2.20.1