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