papermc/CraftBukkit-Patches/0152-Fix-Some-Memory-Leaks.patch

132 lines
4.8 KiB
Diff
Raw Normal View History

2015-04-09 03:18:56 +00:00
From 2eef631711c35d73f487e23a8784bf72f339dffc Mon Sep 17 00:00:00 2001
2014-11-28 01:17:45 +00:00
From: md_5 <git@md-5.net>
Date: Sun, 21 Sep 2014 10:06:01 +1000
Subject: [PATCH] Fix Some Memory Leaks
diff --git a/src/main/java/net/minecraft/server/EnchantmentManager.java b/src/main/java/net/minecraft/server/EnchantmentManager.java
2015-02-28 11:36:22 +00:00
index 9865681..32f5a3e 100644
2014-11-28 01:17:45 +00:00
--- a/src/main/java/net/minecraft/server/EnchantmentManager.java
+++ b/src/main/java/net/minecraft/server/EnchantmentManager.java
2015-02-28 11:36:22 +00:00
@@ -168,7 +168,10 @@ public class EnchantmentManager {
2014-11-28 01:17:45 +00:00
if (entity instanceof EntityHuman) {
2015-02-28 11:36:22 +00:00
a((EnchantmentManager.EnchantmentModifier) EnchantmentManager.d, entityliving.bA());
2014-11-28 01:17:45 +00:00
}
-
+ // Spigot start
+ d.b = null;
+ d.a = null;
+ // Spigot end
}
public static void b(EntityLiving entityliving, Entity entity) {
2015-02-28 11:36:22 +00:00
@@ -181,7 +184,10 @@ public class EnchantmentManager {
2014-11-28 01:17:45 +00:00
if (entityliving instanceof EntityHuman) {
2015-02-28 11:36:22 +00:00
a((EnchantmentManager.EnchantmentModifier) EnchantmentManager.e, entityliving.bA());
2014-11-28 01:17:45 +00:00
}
-
+ // Spigot start
+ e.a = null;
+ e.b = null;
+ // Spigot end
}
public static int a(EntityLiving entityliving) {
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
2015-02-28 11:36:22 +00:00
index 7c23753..134897a 100644
2014-11-28 01:17:45 +00:00
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -1,5 +1,6 @@
package net.minecraft.server;
+import java.lang.ref.WeakReference; // Spigot
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
@@ -24,7 +25,7 @@ public abstract class EntityInsentient extends EntityLiving {
protected NavigationAbstract navigation;
2015-02-28 11:36:22 +00:00
public PathfinderGoalSelector goalSelector; // CraftBukkit - public
public PathfinderGoalSelector targetSelector; // CraftBukkit - public
2014-11-28 01:17:45 +00:00
- private EntityLiving goalTarget;
+ private WeakReference<EntityLiving> goalTarget = new WeakReference<EntityLiving>(null);
2015-02-28 11:36:22 +00:00
private EntitySenses bk;
2014-11-28 01:17:45 +00:00
private ItemStack[] equipment = new ItemStack[5];
2015-02-28 11:36:22 +00:00
public float[] dropChances = new float[5]; // CraftBukkit - public
@@ -84,7 +85,7 @@ public abstract class EntityInsentient extends EntityLiving {
2014-11-28 01:17:45 +00:00
}
public EntityLiving getGoalTarget() {
- return this.goalTarget;
+ return this.goalTarget.get(); // Spigot
}
public void setGoalTarget(EntityLiving entityliving) {
2015-02-28 11:36:22 +00:00
@@ -117,7 +118,7 @@ public abstract class EntityInsentient extends EntityLiving {
2014-11-28 01:17:45 +00:00
entityliving = null;
}
}
- this.goalTarget = entityliving;
+ this.goalTarget = new WeakReference<EntityLiving>(entityliving); // Spigot
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
2015-04-09 03:18:56 +00:00
index c71150a..01c09b1 100644
2014-11-28 01:17:45 +00:00
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
2015-02-28 11:36:22 +00:00
@@ -241,6 +241,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
2014-11-28 01:17:45 +00:00
public void close(IChatBaseComponent ichatbasecomponent) {
// Spigot Start
this.preparing = false;
2015-02-28 11:36:22 +00:00
+ this.i.clear();
2014-11-28 01:17:45 +00:00
// Spigot End
2015-02-28 11:36:22 +00:00
if (this.k.isOpen()) {
this.k.close(); // We can't wait as this may be called from an event loop.
2014-11-28 01:17:45 +00:00
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalSwell.java b/src/main/java/net/minecraft/server/PathfinderGoalSwell.java
2015-02-28 11:36:22 +00:00
index c8eebf8..0c05aee 100644
2014-11-28 01:17:45 +00:00
--- a/src/main/java/net/minecraft/server/PathfinderGoalSwell.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalSwell.java
@@ -3,7 +3,7 @@ package net.minecraft.server;
public class PathfinderGoalSwell extends PathfinderGoal {
EntityCreeper a;
- EntityLiving b;
+ // EntityLiving b; // Spigot
public PathfinderGoalSwell(EntityCreeper entitycreeper) {
this.a = entitycreeper;
@@ -18,22 +18,25 @@ public class PathfinderGoalSwell extends PathfinderGoal {
public void c() {
this.a.getNavigation().n();
- this.b = this.a.getGoalTarget();
+ // this.b = this.a.getGoalTarget(); // Spigot
}
public void d() {
- this.b = null;
+ // this.b = null; // Spigot
}
public void e() {
- if (this.b == null) {
+ // Spigot start
+ EntityLiving b = this.a.getGoalTarget();
+ if (b == null) {
this.a.a(-1);
- } else if (this.a.h(this.b) > 49.0D) {
+ } else if (this.a.h(b) > 49.0D) {
this.a.a(-1);
- } else if (!this.a.getEntitySenses().a(this.b)) {
+ } else if (!this.a.getEntitySenses().a(b)) {
this.a.a(-1);
} else {
this.a.a(1);
}
+ // Spigot end
}
}
--
2.1.0