mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Identified leak
This commit is contained in:
parent
89da5fe08a
commit
a9410d92a2
@ -7,13 +7,10 @@ import com.volmit.iris.scaffold.parallel.BurstExecutor;
|
||||
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.KMap;
|
||||
import com.volmit.iris.util.M;
|
||||
import io.timeandspace.smoothie.OptimizationObjective;
|
||||
import io.timeandspace.smoothie.SmoothieMap;
|
||||
import net.querz.mca.Chunk;
|
||||
import net.querz.mca.MCAFile;
|
||||
import net.querz.mca.MCAUtil;
|
||||
import net.querz.mca.Section;
|
||||
import net.querz.mca.*;
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
import net.querz.nbt.tag.StringTag;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@ -28,14 +25,14 @@ public class DirectWorldWriter {
|
||||
private final File worldFolder;
|
||||
private final Map<Long, MCAFile> writeBuffer;
|
||||
private final Map<Long, Long> lastUse;
|
||||
private static final Map<String, CompoundTag> blockDataCache = SmoothieMap.<String, CompoundTag>newBuilder().build();;
|
||||
private static final Map<String, CompoundTag> blockDataCache = new KMap<>();
|
||||
private static final Map<Biome, Integer> biomeIds = computeBiomeIDs();
|
||||
|
||||
public DirectWorldWriter(File worldFolder)
|
||||
{
|
||||
this.worldFolder = worldFolder;
|
||||
lastUse = SmoothieMap.<Long, Long>newBuilder().build();
|
||||
writeBuffer = SmoothieMap.<Long, MCAFile>newBuilder().build();
|
||||
writeBuffer = new KMap<>();
|
||||
new File(worldFolder, "region").mkdirs();
|
||||
}
|
||||
|
||||
@ -74,10 +71,7 @@ public class DirectWorldWriter {
|
||||
|
||||
lastUse.remove(i);
|
||||
MCAUtil.write(writeBuffer.get(i), f, true);
|
||||
synchronized (writeBuffer)
|
||||
{
|
||||
writeBuffer.remove(i);
|
||||
}
|
||||
writeBuffer.remove(i);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -246,6 +240,15 @@ public class DirectWorldWriter {
|
||||
{
|
||||
try {
|
||||
mca = MCAUtil.read(f);
|
||||
try
|
||||
{
|
||||
mca.cleanupPalettesAndBlockStates();
|
||||
}
|
||||
|
||||
catch(Throwable ee)
|
||||
{
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Iris.warn("Failed to read RandomAccessFile " + f.getAbsolutePath() + ", assuming empty region!");
|
||||
@ -262,10 +265,7 @@ public class DirectWorldWriter {
|
||||
}
|
||||
|
||||
private static Map<Biome, Integer> computeBiomeIDs() {
|
||||
Map<Biome, Integer> biomeIds = SmoothieMap.<Biome, Integer>newBuilder()
|
||||
.expectedSize(Biome.values().length)
|
||||
.optimizeFor(OptimizationObjective.FOOTPRINT)
|
||||
.build();
|
||||
Map<Biome, Integer> biomeIds = new KMap<>();
|
||||
|
||||
for(Biome i : Biome.values())
|
||||
{
|
||||
|
@ -176,8 +176,6 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
default void generateParallaxLayer(int x, int z, boolean force)
|
||||
{
|
||||
if(!force && getParallaxAccess().isParallaxGenerated(x >> 4, z >> 4))
|
||||
@ -426,6 +424,8 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer
|
||||
try
|
||||
{
|
||||
BlockVector bv = IrisObject.sampleSize(getData().getObjectLoader().findFile(i));
|
||||
warn(i, bv);
|
||||
|
||||
synchronized (xg)
|
||||
{
|
||||
xg.getAndSet(Math.max(bv.getBlockX(), xg.get()));
|
||||
@ -482,6 +482,14 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer
|
||||
return x;
|
||||
}
|
||||
|
||||
default void warn(String ob, BlockVector bv)
|
||||
{
|
||||
if(Math.max(bv.getBlockX(), bv.getBlockZ()) > 128)
|
||||
{
|
||||
Iris.warn("Object " + ob + " has a large size (" + bv.toString() + ") and may increase memory usage!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
default int getHighest(int x, int z) {
|
||||
return getHighest(x,z,false);
|
||||
|
@ -56,7 +56,6 @@ public class ParallaxRegion extends HunkRegion
|
||||
|
||||
public ParallaxChunkMeta getMetaR(int x, int z)
|
||||
{
|
||||
lastUse = M.ms();
|
||||
return getMetaHunkR().getOr(x, 0, z, new ParallaxChunkMeta());
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.volmit.iris.scaffold.parallax;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
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 com.volmit.iris.util.*;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.io.File;
|
||||
@ -25,7 +23,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
this.folder = folder;
|
||||
save = new KList<>();
|
||||
loadedRegions = new KMap<>();
|
||||
cleanup = new ChronoLatch(5000);
|
||||
cleanup = new ChronoLatch(1000);
|
||||
folder.mkdirs();
|
||||
}
|
||||
|
||||
@ -205,6 +203,8 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
|
||||
@Override
|
||||
public void cleanup(long r, long c) {
|
||||
Iris.info("P: c" + Form.f(getChunkCount()) + " / r" + getRegionCount());
|
||||
|
||||
J.a(() -> {
|
||||
for(ParallaxRegion i : loadedRegions.v())
|
||||
{
|
||||
|
@ -209,8 +209,6 @@ public class PregenJob implements Listener
|
||||
tick(skip);
|
||||
}
|
||||
|
||||
Iris.warn("Size: " + writer.size());
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
|
||||
if(PaperLib.isPaper())
|
||||
|
@ -118,9 +118,19 @@ public class Section {
|
||||
* @return The block state data of this block.
|
||||
*/
|
||||
public CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) {
|
||||
int index = getBlockIndex(blockX, blockY, blockZ);
|
||||
int paletteIndex = getPaletteIndex(index);
|
||||
return palette.get(paletteIndex);
|
||||
try
|
||||
{
|
||||
int index = getBlockIndex(blockX, blockY, blockZ);
|
||||
int paletteIndex = getPaletteIndex(index);
|
||||
return palette.get(paletteIndex);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user