Synchronize on chunk manager swap/move to avoid OOM

This commit is contained in:
Jesse Boyd 2018-07-05 19:34:24 +10:00
parent cc97c8d21e
commit bcfc7275ad
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -47,6 +47,7 @@ public class FaweChunkManager extends ChunkManager {
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
synchronized (FaweChunkManager.class) {
EditSession sessionA = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession sessionB = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
CuboidRegion regionA = new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ()));
@ -63,6 +64,7 @@ public class FaweChunkManager extends ChunkManager {
}
TaskManager.IMP.task(whenDone);
}
}
});
}
@ -71,6 +73,7 @@ public class FaweChunkManager extends ChunkManager {
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
synchronized (FaweChunkManager.class) {
EditSession from = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession to = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
CuboidRegion region = new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ()));
@ -81,6 +84,7 @@ public class FaweChunkManager extends ChunkManager {
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
}
}
TaskManager.IMP.task(whenDone);
}
});
@ -92,6 +96,7 @@ public class FaweChunkManager extends ChunkManager {
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
synchronized (FaweChunkManager.class) {
EditSession editSession = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
World world = editSession.getWorld();
CuboidRegion region = new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ()));
@ -99,6 +104,7 @@ public class FaweChunkManager extends ChunkManager {
editSession.flushQueue();
TaskManager.IMP.task(whenDone);
}
}
});
return true;
}