mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Fixing a memory leak involving mob tracking.
This commit is contained in:
parent
e7ceef479e
commit
643af1c32b
@ -29,6 +29,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
public HashMap<String, ChunkStore> store = new HashMap<String, ChunkStore>();
|
public HashMap<String, ChunkStore> store = new HashMap<String, ChunkStore>();
|
||||||
public ArrayList<BlockStoreConversionZDirectory> converters = new ArrayList<BlockStoreConversionZDirectory>();
|
public ArrayList<BlockStoreConversionZDirectory> converters = new ArrayList<BlockStoreConversionZDirectory>();
|
||||||
private HashMap<UUID, Boolean> oldData = new HashMap<UUID, Boolean>();
|
private HashMap<UUID, Boolean> oldData = new HashMap<UUID, Boolean>();
|
||||||
|
// TODO: Investigate whether or not a LinkedList would be faster
|
||||||
private List<Entity> spawnedMobs = new ArrayList<Entity>();
|
private List<Entity> spawnedMobs = new ArrayList<Entity>();
|
||||||
private List<Entity> mobsToRemove = new ArrayList<Entity>();
|
private List<Entity> mobsToRemove = new ArrayList<Entity>();
|
||||||
private List<String> savedChunks = new ArrayList<String>();
|
private List<String> savedChunks = new ArrayList<String>();
|
||||||
@ -207,8 +208,8 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
iteratingMobs = true;
|
iteratingMobs = true;
|
||||||
|
|
||||||
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
||||||
tempSpawnedMobs.remove(removalCheckedMobs);
|
tempSpawnedMobs.removeAll(removalCheckedMobs);
|
||||||
tempSpawnedMobs.remove(checkedMobs);
|
tempSpawnedMobs.removeAll(checkedMobs);
|
||||||
for (Entity entity : tempSpawnedMobs) {
|
for (Entity entity : tempSpawnedMobs) {
|
||||||
if (!isEntityInChunk(entity, cx, cz, world))
|
if (!isEntityInChunk(entity, cx, cz, world))
|
||||||
continue;
|
continue;
|
||||||
@ -218,7 +219,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (safeToRemoveMobs) {
|
if (safeToRemoveMobs) {
|
||||||
spawnedMobs.remove(mobsToRemove);
|
spawnedMobs.removeAll(mobsToRemove);
|
||||||
mobsToRemove.clear();
|
mobsToRemove.clear();
|
||||||
removalCheckedMobs.clear();
|
removalCheckedMobs.clear();
|
||||||
iteratingMobs = false;
|
iteratingMobs = false;
|
||||||
@ -237,7 +238,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
boolean unloaded = false;
|
boolean unloaded = false;
|
||||||
if (!store.containsKey(world.getName() + "," + cx + "," + cz)) {
|
if (!store.containsKey(world.getName() + "," + cx + "," + cz)) {
|
||||||
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
||||||
tempSpawnedMobs.remove(checkedMobs);
|
tempSpawnedMobs.removeAll(checkedMobs);
|
||||||
for (Entity entity : tempSpawnedMobs) {
|
for (Entity entity : tempSpawnedMobs) {
|
||||||
if (!isEntityInChunk(entity, cx, cz, world))
|
if (!isEntityInChunk(entity, cx, cz, world))
|
||||||
continue;
|
continue;
|
||||||
@ -257,7 +258,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
ChunkStore out = store.get(world.getName() + "," + cx + "," + cz);
|
ChunkStore out = store.get(world.getName() + "," + cx + "," + cz);
|
||||||
|
|
||||||
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
||||||
tempSpawnedMobs.remove(checkedMobs);
|
tempSpawnedMobs.removeAll(checkedMobs);
|
||||||
for (Entity entity : tempSpawnedMobs) {
|
for (Entity entity : tempSpawnedMobs) {
|
||||||
if (!isEntityInChunk(entity, cx, cz, world))
|
if (!isEntityInChunk(entity, cx, cz, world))
|
||||||
continue;
|
continue;
|
||||||
@ -341,7 +342,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
||||||
tempSpawnedMobs.remove(checkedMobs);
|
tempSpawnedMobs.removeAll(checkedMobs);
|
||||||
for (Entity entity : tempSpawnedMobs) {
|
for (Entity entity : tempSpawnedMobs) {
|
||||||
World entityWorld = entity.getWorld();
|
World entityWorld = entity.getWorld();
|
||||||
|
|
||||||
@ -389,8 +390,8 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
safeToRemoveMobs = false;
|
safeToRemoveMobs = false;
|
||||||
|
|
||||||
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
||||||
tempSpawnedMobs.remove(checkedMobs);
|
tempSpawnedMobs.removeAll(checkedMobs);
|
||||||
tempSpawnedMobs.remove(removalCheckedMobs);
|
tempSpawnedMobs.removeAll(removalCheckedMobs);
|
||||||
for (Entity entity : tempSpawnedMobs) {
|
for (Entity entity : tempSpawnedMobs) {
|
||||||
World entityWorld = entity.getWorld();
|
World entityWorld = entity.getWorld();
|
||||||
|
|
||||||
@ -405,7 +406,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
|
|
||||||
safeToRemoveMobs = true;
|
safeToRemoveMobs = true;
|
||||||
|
|
||||||
spawnedMobs.remove(mobsToRemove);
|
spawnedMobs.removeAll(mobsToRemove);
|
||||||
mobsToRemove.clear();
|
mobsToRemove.clear();
|
||||||
checkedMobs.clear();
|
checkedMobs.clear();
|
||||||
removalCheckedMobs.clear();
|
removalCheckedMobs.clear();
|
||||||
@ -615,7 +616,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
mobsToRemove.add(entity);
|
mobsToRemove.add(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
spawnedMobs.remove(mobsToRemove);
|
spawnedMobs.removeAll(mobsToRemove);
|
||||||
mobsToRemove.clear();
|
mobsToRemove.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user