Decrease cache size if max memory is small

This commit is contained in:
mcrcortex
2025-06-23 19:39:18 +10:00
parent b3556813a9
commit d86c3b2eb8

View File

@@ -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) {