Paper/CraftBukkit-Patches/0169-Plug-WorldMap-Memory-Leak.patch

64 lines
2.5 KiB
Diff
Raw Normal View History

From 4bc8530bcd9f6864a0c13ef77022e63b12f9409c 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/PersistentCollection.java b/src/main/java/net/minecraft/server/PersistentCollection.java
index 4684e89..e9469a5 100644
--- a/src/main/java/net/minecraft/server/PersistentCollection.java
+++ b/src/main/java/net/minecraft/server/PersistentCollection.java
@@ -18,7 +18,7 @@ public class PersistentCollection {
private IDataManager a;
private Map b = new HashMap();
- private List c = new ArrayList();
+ public List c = new ArrayList(); // Spigot
private Map d = new HashMap();
public PersistentCollection(IDataManager idatamanager) {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 6100297..7a547da 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1170,6 +1170,23 @@ public abstract class World implements IBlockAccess {
entity.die();
if (entity instanceof EntityHuman) {
this.players.remove(entity);
+ // Spigot start
+ for ( Object o : worldMaps.c )
+ {
+ if ( o instanceof WorldMap )
+ {
+ WorldMap map = (WorldMap) o;
+ map.i.remove( entity );
+ for ( Iterator<WorldMapHumanTracker> iter = (Iterator<WorldMapHumanTracker>) map.f.iterator(); iter.hasNext(); )
+ {
+ if ( iter.next().trackee == entity )
+ {
+ iter.remove();
+ }
+ }
+ }
+ }
+ // Spigot end
this.everyoneSleeping();
}
}
diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java
index bd5cfca..3254b87 100644
--- a/src/main/java/net/minecraft/server/WorldMap.java
+++ b/src/main/java/net/minecraft/server/WorldMap.java
@@ -22,7 +22,7 @@ public class WorldMap extends PersistentBase {
public byte scale;
public byte[] colors = new byte[16384];
public List f = new ArrayList();
- private Map i = new HashMap();
+ public Map i = new HashMap(); // Spigot
public Map decorations = new LinkedHashMap();
// CraftBukkit start
--
1.9.1