From 2c4cb91ff721dec7ce9336794d9a64a1ca72224b Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Sat, 8 Apr 2023 15:57:52 +0200 Subject: [PATCH] Added minimum memory requirement --- src/main/java/net/raphimc/viaproxy/ViaProxy.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/net/raphimc/viaproxy/ViaProxy.java b/src/main/java/net/raphimc/viaproxy/ViaProxy.java index 3a6753d..e84cd60 100644 --- a/src/main/java/net/raphimc/viaproxy/ViaProxy.java +++ b/src/main/java/net/raphimc/viaproxy/ViaProxy.java @@ -96,6 +96,16 @@ public class ViaProxy { ConsoleHandler.hookConsole(); Logger.LOGGER.info("Initializing ViaProxy {} v{} (Injected using {})...", hasUI ? "GUI" : "CLI", VERSION, injectionMethod); Logger.LOGGER.info("Using java version: " + System.getProperty("java.vm.name") + " " + System.getProperty("java.version") + " (" + System.getProperty("java.vendor") + ") on " + System.getProperty("os.name")); + Logger.LOGGER.info("Available memory (bytes): " + Runtime.getRuntime().maxMemory()); + + if (Runtime.getRuntime().maxMemory() < 512 * 1024 * 1024) { + Logger.LOGGER.fatal("ViaProxy is not able to run with less than 512MB of RAM."); + if (hasUI) { + JOptionPane.showMessageDialog(null, "ViaProxy is not able to run with less than 512MB of RAM.", "Critical Error", JOptionPane.ERROR_MESSAGE); + System.exit(1); + } + } + loadNetty(); saveManager = new SaveManager(); PluginManager.loadPlugins();