Process entity ticks on worlds without players. Fixes BUKKIT-2031

Both the CB 1.3.1 code, and vanilla 1.3.1 code, have modified the
behavior of entity tick processing in a way that can lead to disabling
of entity cleanup. Specifically, the tickEntities() call in n.m.s.World,
which processes both the entity cleanup (removing from the world entity
list) and tile entity tick processing (furnaces and such) does not get
called by n.m.s.MinecraftServer's q() method (which drives tick
processing calls in general) when no players are on the given world.
This causes a serious memory leak when automation processes, like dynmap
mapping, load and unload chunks - as entities on unloaded chunks are
only cleaned up during entity tick processing. It also will cause issues
with any mods that use persistent chunk loading (that is, keeping chunks
loaded so that tile entities will continue being processed), since such
processing will no longer function without at least one player on the
given world.

In any case, the tickEntities() call should be called in the same
fashion as under 1.2.x (each tick, independent of player population, as
opposed to being suspended indefinitely when no players are on the given
world). The specific memory leak observed, with removing the unloaded
entites from the world, requires this call be made regularly (or, at
least, whenever the entity unload queue (world.g) is not empty.

Closes GH-832
This commit is contained in:
Mike Primm 2012-08-03 01:19:10 -05:00 committed by Wesley Wolfe
parent f5794937a9
commit fe8fc6b90e

View File

@ -539,7 +539,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC
while (true) { while (true) {
if (!worldserver.updateLights()) { if (!worldserver.updateLights()) {
// this.methodProfiler.b(); // CraftBukkit - not in production code // this.methodProfiler.b(); // CraftBukkit - not in production code
if (!worldserver.players.isEmpty()) { if (true || !worldserver.players.isEmpty()) { // CraftBukkit - this prevents entity cleanup, other issue on servers with no players
worldserver.tickEntities(); worldserver.tickEntities();
} }