From 45cc55c4a19d0ca161b8a0123ae1a56961306b81 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 17 Sep 2021 08:48:57 +0200 Subject: [PATCH] Memory threshold Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/Node.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/Node.java b/src/de/steamwar/bungeecore/Node.java index 5336491..ea0a2ed 100644 --- a/src/de/steamwar/bungeecore/Node.java +++ b/src/de/steamwar/bungeecore/Node.java @@ -34,7 +34,7 @@ public abstract class Node { private static final List JVM_ARGS = Arrays.asList("-Dlog4j.configurationFile=log4j2.xml", "-server", "-Xms128M", "-XX:+UseCompressedOops", "-XX:+TieredCompilation", "-XX:TargetSurvivorRatio=90", "-XX:SurvivorRatio=8", "-XX:MaxTenuringThreshold=15", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseBiasedLocking", "-XX:UseSSE=3", "-XX:+UseCodeCacheFlushing", "-XX:+UseThreadPriorities", "-XX:+AggressiveOpts", "-XX:+ReduceSignalUsage", "-XX:+UseInterpreter", "-XX:+UseSharedSpaces", "-XX:AllocatePrefetchStyle=1", "-XX:+AlwaysCompileLoopMethods", "-XX:+UseConcMarkSweepGC", "-XX:+RewriteFrequentPairs", "-XX:+OptimizeStringConcat", "-XX:+CMSCleanOnEnter", "-XX:+UseInlineCaches"); private static final List JVM8_ARGS = Arrays.asList("-XX:ThreadPriorityPolicy=42", "-XX:SharedReadOnlySize=30m", "-XX:+UseFastEmptyMethods", "-XX:+UseFastAccessorMethods"); - private static final long minFreeMem = 4L * 1024 * 1024; // 4 GB + private static final double MIN_FREE_MEM = 4.0 * 1024 * 1024; // 4 GiB private static final List nodes = new ArrayList<>(); public static Node local = null; @@ -161,7 +161,7 @@ public abstract class Node { throw new SecurityException("Could not read local cpu", e); } - return cpuLoad / cores + freeMem > minFreeMem ? 0 : ((totalMem - freeMem) / totalMem); + return cpuLoad / cores + (freeMem > MIN_FREE_MEM ? 0 : ((totalMem - freeMem) / totalMem)); } } @@ -251,7 +251,7 @@ public abstract class Node { double totalMem = Double.parseDouble(bufferedReader.readLine().replaceAll(" +", " ").split(" ")[1]); bufferedReader.readLine(); double freeMem = Double.parseDouble(bufferedReader.readLine().replaceAll(" +", " ").split(" ")[1]); - return cpuLoad / cores + freeMem > minFreeMem ? 0 : ((totalMem - freeMem) / totalMem); + return cpuLoad / cores + (freeMem > MIN_FREE_MEM ? 0 : ((totalMem - freeMem) / totalMem)); } catch (IOException e) { BungeeCore.get().getLogger().log(Level.SEVERE, "Could read load", e); return Double.POSITIVE_INFINITY;