mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
Fix the leak
This commit is contained in:
parent
5878128746
commit
56ae387f7b
@ -401,4 +401,16 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
int getPrecacheSize();
|
int getPrecacheSize();
|
||||||
|
|
||||||
Chunk generatePaper(World world, int cx, int cz);
|
Chunk generatePaper(World world, int cx, int cz);
|
||||||
|
|
||||||
|
default int getParallaxChunkCount()
|
||||||
|
{
|
||||||
|
int v= 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < getCompound().getSize(); i++)
|
||||||
|
{
|
||||||
|
v += getCompound().getEngine(i).getParallax().getChunkCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package com.volmit.iris.scaffold.hunk.io;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||||
|
import com.volmit.iris.scaffold.parallel.BurstExecutor;
|
||||||
|
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.*;
|
import com.volmit.iris.util.*;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
@ -78,12 +80,19 @@ public class HunkRegionSlice<T>
|
|||||||
|
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
|
BurstExecutor e = MultiBurst.burst.burst(save.size());
|
||||||
for(ChunkPosition i : save.copy())
|
for(ChunkPosition i : save.copy())
|
||||||
{
|
{
|
||||||
save(i.getX(), i.getZ());
|
if(i == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
save.clear();
|
e.queue(() -> save(i.getX(), i.getZ()));
|
||||||
|
save.remove(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
e.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(int x, int z)
|
public boolean contains(int x, int z)
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package com.volmit.iris.scaffold.parallax;
|
package com.volmit.iris.scaffold.parallax;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
|
||||||
import com.volmit.iris.IrisSettings;
|
import com.volmit.iris.IrisSettings;
|
||||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||||
import com.volmit.iris.util.*;
|
import com.volmit.iris.util.ChronoLatch;
|
||||||
|
import com.volmit.iris.util.J;
|
||||||
|
import com.volmit.iris.util.KList;
|
||||||
|
import com.volmit.iris.util.KMap;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -23,7 +25,7 @@ public class ParallaxWorld implements ParallaxAccess
|
|||||||
this.folder = folder;
|
this.folder = folder;
|
||||||
save = new KList<>();
|
save = new KList<>();
|
||||||
loadedRegions = new KMap<>();
|
loadedRegions = new KMap<>();
|
||||||
cleanup = new ChronoLatch(1000);
|
cleanup = new ChronoLatch(5000);
|
||||||
folder.mkdirs();
|
folder.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,12 +103,12 @@ public class ParallaxWorld implements ParallaxAccess
|
|||||||
save.remove(key);
|
save.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
v += loadedRegions.remove(key).unload();
|
ParallaxRegion lr = loadedRegions.remove(key);
|
||||||
}
|
|
||||||
|
|
||||||
else
|
if(lr != null)
|
||||||
{
|
{
|
||||||
Iris.warn("Cant unload region " + x + " " + z + " because it's not loaded.");
|
v += lr.unload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
@ -210,8 +212,9 @@ public class ParallaxWorld implements ParallaxAccess
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanup(long r, long c) {
|
public void cleanup(long r, long c) {
|
||||||
|
|
||||||
J.a(() -> {
|
J.a(() -> {
|
||||||
|
try
|
||||||
|
{
|
||||||
int rr = 0;
|
int rr = 0;
|
||||||
int cc = 0;
|
int cc = 0;
|
||||||
|
|
||||||
@ -228,10 +231,12 @@ public class ParallaxWorld implements ParallaxAccess
|
|||||||
cc+= i.cleanup(c);
|
cc+= i.cleanup(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Iris.info("Unloaded " + rr + " Regions and " + cc + " Chunks");
|
catch(Throwable e)
|
||||||
Iris.info("P: c" + Form.f(getChunkCount()) + " / r" + getRegionCount());
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public class MultiBurst
|
|||||||
tid++;
|
tid++;
|
||||||
Thread t = new Thread(r);
|
Thread t = new Thread(r);
|
||||||
t.setName("Iris Generator " + tid);
|
t.setName("Iris Generator " + tid);
|
||||||
t.setPriority(Thread.MAX_PRIORITY);
|
t.setPriority(6);
|
||||||
t.setUncaughtExceptionHandler((et, e) ->
|
t.setUncaughtExceptionHandler((et, e) ->
|
||||||
{
|
{
|
||||||
Iris.info("Exception encountered in " + et.getName());
|
Iris.info("Exception encountered in " + et.getName());
|
||||||
|
@ -19,7 +19,7 @@ public class J
|
|||||||
tid++;
|
tid++;
|
||||||
Thread t = new Thread(r);
|
Thread t = new Thread(r);
|
||||||
t.setName("Iris Actuator " + tid);
|
t.setName("Iris Actuator " + tid);
|
||||||
t.setPriority(Thread.MIN_PRIORITY);
|
t.setPriority(8);
|
||||||
t.setUncaughtExceptionHandler((et, e) ->
|
t.setUncaughtExceptionHandler((et, e) ->
|
||||||
{
|
{
|
||||||
Iris.info("Exception encountered in " + et.getName());
|
Iris.info("Exception encountered in " + et.getName());
|
||||||
|
@ -18,7 +18,10 @@ import org.bukkit.event.world.ChunkUnloadEvent;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class PregenJob implements Listener
|
public class PregenJob implements Listener
|
||||||
@ -53,7 +56,7 @@ public class PregenJob implements Listener
|
|||||||
private double cps = 0;
|
private double cps = 0;
|
||||||
private int lg = 0;
|
private int lg = 0;
|
||||||
private long lt = M.ms();
|
private long lt = M.ms();
|
||||||
private int cubeSize = 9;
|
private int cubeSize = 32;
|
||||||
private long nogen = M.ms();
|
private long nogen = M.ms();
|
||||||
private KList<ChunkPosition> requeueMCA = new KList<ChunkPosition>();
|
private KList<ChunkPosition> requeueMCA = new KList<ChunkPosition>();
|
||||||
private RollingSequence acps = new RollingSequence(PaperLib.isPaper() ? 8 : 32);
|
private RollingSequence acps = new RollingSequence(PaperLib.isPaper() ? 8 : 32);
|
||||||
@ -64,6 +67,25 @@ public class PregenJob implements Listener
|
|||||||
private final DirectWorldWriter writer;
|
private final DirectWorldWriter writer;
|
||||||
int xc = 0;
|
int xc = 0;
|
||||||
private IrisAccess access = null;
|
private IrisAccess access = null;
|
||||||
|
private static int tid = 0;
|
||||||
|
private static final ExecutorService e = Executors.newCachedThreadPool(new ThreadFactory()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Thread newThread(Runnable r)
|
||||||
|
{
|
||||||
|
tid++;
|
||||||
|
Thread t = new Thread(r);
|
||||||
|
t.setName("Iris Pregen Worker " + tid);
|
||||||
|
t.setPriority(3);
|
||||||
|
t.setUncaughtExceptionHandler((et, e) ->
|
||||||
|
{
|
||||||
|
Iris.info("Exception encountered in " + et.getName());
|
||||||
|
e.printStackTrace();
|
||||||
|
});
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
|
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
|
||||||
{
|
{
|
||||||
@ -439,7 +461,7 @@ public class PregenJob implements Listener
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
J.a(g);
|
e.execute(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -447,7 +469,7 @@ public class PregenJob implements Listener
|
|||||||
{
|
{
|
||||||
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.magenta.darker().darker().darker());
|
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.magenta.darker().darker().darker());
|
||||||
}
|
}
|
||||||
J.a(() ->
|
e.execute(() ->
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -626,7 +648,7 @@ public class PregenJob implements Listener
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
vv.add("Parallelism: " + access().getCompound().getCurrentlyGeneratingEngines());
|
vv.add("Parallelism: " + access().getCompound().getCurrentlyGeneratingEngines());
|
||||||
vv.add("Precache : " + access().getPrecacheSize());
|
vv.add("Plax Cache : " + Form.f(access().getParallaxChunkCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(Throwable e)
|
catch(Throwable e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user