Fix for unlucky memory leak

This commit is contained in:
mcrcortex
2024-01-21 21:51:12 +10:00
parent c3e7f5db67
commit 685c5cc587
2 changed files with 7 additions and 1 deletions

View File

@@ -145,6 +145,9 @@ public class GeometryManager {
}
public void free() {
while (!this.buildResults.isEmpty()) {
this.buildResults.pop().free();
}
this.sectionMetaBuffer.free();
this.geometryBuffer.free();
}

View File

@@ -57,6 +57,8 @@ public class RenderGenerationService {
int buildFlags = task.flagSupplier.applyAsInt(section);
if (buildFlags != 0) {
var mesh = factory.generateMesh(section, buildFlags);
section.release();
this.resultConsumer.accept(mesh.clone());
if (false) {
@@ -67,10 +69,11 @@ public class RenderGenerationService {
} else {
mesh.free();
}
}
} else {
section.release();
}
}
}
//TODO: Add a priority system, higher detail sections must always be updated before lower detail
// e.g. priorities NONE->lvl0 and lvl1 -> lvl0 over lvl0 -> lvl1