From d86c3b2eb84e68ee79cea8114de52c1832723b97 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Mon, 23 Jun 2025 19:39:18 +1000 Subject: [PATCH] Decrease cache size if max memory is small --- src/main/java/me/cortex/voxy/common/world/WorldEngine.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/cortex/voxy/common/world/WorldEngine.java b/src/main/java/me/cortex/voxy/common/world/WorldEngine.java index cf3334eb..b31ce2b7 100644 --- a/src/main/java/me/cortex/voxy/common/world/WorldEngine.java +++ b/src/main/java/me/cortex/voxy/common/world/WorldEngine.java @@ -52,10 +52,15 @@ public class WorldEngine { public WorldEngine(SectionStorage storage, @Nullable VoxyInstance instance) { this.instanceIn = instance; + int cacheSize = 1024; + if (Runtime.getRuntime().maxMemory()>=(1L<<32)-200<<20) { + cacheSize = 2048; + } + this.storage = storage; this.mapper = new Mapper(this.storage); //5 cache size bits means that the section tracker has 32 separate maps that it uses - this.sectionTracker = new ActiveSectionTracker(6, storage::loadSection, 2048, this); + this.sectionTracker = new ActiveSectionTracker(6, storage::loadSection, cacheSize, this); } public WorldSection acquireIfExists(int lvl, int x, int y, int z) {