From 3684174b67cbf796d145659427790b9ac1f91fd6 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Mon, 21 Apr 2025 16:51:33 +1000 Subject: [PATCH] Cap save queue --- .../common/world/service/SectionSavingService.java | 12 ++++++++++++ src/main/resources/assets/voxy/lang/en_us.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/cortex/voxy/common/world/service/SectionSavingService.java b/src/main/java/me/cortex/voxy/common/world/service/SectionSavingService.java index 4b33623d..49c4733f 100644 --- a/src/main/java/me/cortex/voxy/common/world/service/SectionSavingService.java +++ b/src/main/java/me/cortex/voxy/common/world/service/SectionSavingService.java @@ -50,6 +50,18 @@ public class SectionSavingService { if (!section.inSaveQueue.getAndSet(true)) { //Acquire the section for use section.acquire(); + + //Hard limit the save count to prevent OOM + if (this.getTaskCount() > 5_000) { + while (this.getTaskCount() > 5_000) { + try { + Thread.sleep(10); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } + this.saveQueue.add(new SaveEntry(in, section)); this.threads.execute(); } diff --git a/src/main/resources/assets/voxy/lang/en_us.json b/src/main/resources/assets/voxy/lang/en_us.json index 85e99f72..30a8051c 100644 --- a/src/main/resources/assets/voxy/lang/en_us.json +++ b/src/main/resources/assets/voxy/lang/en_us.json @@ -1,5 +1,5 @@ { - "voxy.config.title": "Voxy config", + "voxy.config.title": "Voxy", "voxy.config.general.enabled": "Enable Voxy", "voxy.config.general.enabled.tooltip": "Fully enables or disables voxy",